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 zfacmilan at 2007-11-10 18:49:09 on Problem 3292
#include<iostream>
#include<string>
using namespace std;


int main()
{
    int * a;
    a = new int [1000002];
    unsigned i, j, k, m;
    for(i=0;i<1000002;i++){a[i] = 0;}
    
    for(i = 1;i <= 1000001; i += 4)
          a[i] ++;
    for(i = 5; i <= 1000001  ; i+=4){
          for(j = i ;(j <= 1000001 ) &&(i * j  <= 1000001); j +=4){
                         a[i * j] = (a[i] > a[j] ? a[i] : a[j]) + 1 ; 
          }
    }
    
    
    int input;
    while(cin >> input){
              if(!input){
                         break;
              }
              for(k = 5,m = 0 ;k <= input ;k+=4){
                    if(a[k] == 2){
                            m ++ ;
                    }
              }
              cout <<input << " "<< m << endl;
    }
    delete []a;                       
    
}

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