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 |
有区别吗?这两个有什么区别,一个AC一个WA. #include<iostream> using namespace std; int main(){ unsigned long input; while(cin>>input){ unsigned long total=0; for(int i=1;i<input;i++){ if(i%2==0){ if( (input-i/2)/i <= (i/2 - 1) ) break; if((input-i/2)%i==0 ) total++; } else { if( (input/i)-(i-1)/2 <= 0 ) break; if(input%i==0 ) total++; } } cout<<total<<endl; } } ----------------- #include<iostream> using namespace std; int main(){ unsigned long input; while(cin>>input){ unsigned long total=0; for(int i=1;i<input;i++){ if(i%2==0){ if((input-i/2)%i==0 && (input-i/2)/i > (i/2 - 1)) total++; } else if(input%i==0 && (input/i)-(i-1)/2 > 0) total++; } cout<<total<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator