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 zyz at 2007-04-21 08:18:02 on Problem 2140
这两个有什么区别,一个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:
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