⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1049b.cpp

📁 威士忌的HDU题解.大概有260多题的源码。对于学习非常有好处。
💻 CPP
字号:
/*
1049b Climbing Worm
Time Limit : 1000 ms  Memory Limit : 32768 K  Output Limit : 5120 K

GUN C++
*/
#include <iostream.h>
//#include <fstream.h>
using namespace std;

//ofstream fout( "results.txt", ios::app );

int method1(int n,int d,int u)
{
    int ians;
    ians=0;
    while(n-u>0)
    {
        n=n-u+d;
        ians+=2;
    }
    ians++;
    cout<<ians<<endl;
    //fout<<"1049:"<<ians<<endl;
    return 0;
}


int method2(int n,int d,int u)
{
    int ians;
    ians=(n-u)/(u-d);
    if((n-u)%(u-d)!=0)
    {   ians++;ians*=2;}
    else
    {   ians*=2;}
    ians++;
    cout<<ians<<endl;
    //fout<<"1049b:"<<ians<<endl;
    return 0;
}

int main()
{
    int n,d,u,ians;

    while(cin>>n>>u>>d && (n!=0))
    {
        //method1(n,d,u);
        method2(n,d,u);
    }
    //fout.close();
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -