| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
请问怎样不超时#include<iostream.h>
void main()
{
int N[50],n=1,i=0,num=0,status=1;
while(n)
{
cin>>n;
if(n!=0)
{
N[i]=n;
i++;
}
}
for(int j=0;j<i;j++)
{
if(N[j]<=6)
cout<<j+1<<endl;
else
{
num=6;
int k=7;
while(num!=N[j])
{
status=1;
int p=k,mark=0;
while(status)
{
mark=p;
if(p%2==0)
p=p/2;
if(p%3==0)
p=p/3;
if(p%5==0)
p=p/5;
if(p==mark||p==1) status=0;
}
if(p==1) num++;
++k;
}
cout<<k-1<<endl;
}
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator