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 qinwei at 2007-07-13 13:27:25 on Problem 1316
#include<iostream.h>
int main(){
    bool nn[10000];
    int i,j;
    
    for(i=1;i<10000;i++){
          if(i>=1000)
          j=i+i%10+(i/10)%10+(i/100)%10+(i/1000)%10;
          else if(i>=100)
          j=i+(i/100)%10+(i/10)%10+i%10;
          else if(i>=10)
          j=i+(i/10)%10+i%10;
          else
          j=i+i;
                           
          nn[j]=0;
          }
    
    for(j=1;j<10000;j++)
    if(nn[j])
    cout<<j<<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