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

看出问题的不吝赐教,谢谢

Posted by Huacm42 at 2006-08-24 23:25:54 on Problem 1338
不知为何在编译时出现死循环,想了许久没有头绪,哪位大虾指点一下谢谢~!
#include<iostream>
using namespace std;
int main()
{
     int a[1501],i,k,k1=1,n,s=1,flag;
    while(s<=1500)
    {
            k=k1;
           while(1)
            {
                      flag=0;                 //每次将flag重新置0 
                      if(k%2==0) {k/=2;flag=1;}
                      if(k%3==0) {k/=3;flag=1;}//若可整除就置为1 
                      if(k%5==0) {k/=5;flag=1;}                                                                 
                      if(flag==0||k==1) break; 
            }
            if(k==1) {a[s]=k1;s++;}          //k=1是 符合条件的数 
            k1++;
             
    }  
   while(1)
   {
           cin>>n;
           if(n==0) break;
           cout<<a[n]<<endl;
   }
    return 0;
}

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