HDU 1049

#include <iostream>

using namespace std;

int main(){
    int n,u,d,sum;
    while(cin>>n>>u>>d&&n){

            int k = (n-u)/(u-d);
            if( (n-u)%(u-d) )
                
                k++;

                sum=k*2+1;
            cout<<sum<<endl;


    }
    return 0;
    }


OJ上的评测很严格,提交了几次都是WA,因为

#include <iostream>

using namespace std;

int main(){
    int n,u,d,sum;
    while(cin>>n>>u>>d&&n){

           int k = (n-u)/(u-d);
           int d= (n-u)%(u-d);//在这里对d又定义了一次int型,提交为WA,去掉int即可AC
                if(d)
                k++;

                sum=k*2+1;
            cout<<sum<<endl;


    }
    return 0;
    }


 

原文地址:https://www.cnblogs.com/zhangmingzhao/p/7256484.html