Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

5

Posted by 861118 at 2009-09-14 09:58:28 on Problem 1638
#include<iostream>
using namespace std;
void main()
{int a[10], t;
void f(int);
cin>>t;cout<<t<<endl;
for(int i=1;i<=t;i++)
cin>>a[i]; 
for(i=1;i<=t;i++)
f(a[i]);
}
void f(int n){
int prime(int n);
int d=0,b=0,i=1,m,j;

while(n>=1)
{if(n>=1&&n<=3){if(i%2==1){d=d+1;n=n-1;i++;f(n);}
                else {b=b+1;n=n-1;i++;f(n);}}
else {if(prime(n)==1){if(i%2==1)d=d+1,n=n-1,i++,f(n);}
      else{j=i,i++,m=n,n=prime(n),f(n);
           i=j,i++,n=m/prime(n),f(n);}}
}
cout<<d<<"   "<<b<<endl;}
int prime(int n)
{int c=1;
for(int i=2;i<=n;i++)
{if(n%i==0)c=i;break;}
return c;}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator