zoukankan      html  css  js  c++  java
  • POJ 1781

    #include <iostream>
    #include <string>
    #include <cmath>
    using namespace std;
    unsigned fun(unsigned num);
    int main()
    {
        //freopen("acm.acm","r",stdin);
        string s;
        unsigned num;
        unsigned i;
        while(cin>>s,s != "00e0")
        {
            num = 0;
            num += (s[0]-'0')*10;
            num += s[1]-'0';
            num *= pow((double)10,(double)(s[3]-'0'));
            i = fun(num);
    //        cout<<i<<"  **********8  "<<endl;
        //    cout<<"num "<<num<<endl;
        //            cout<<i<< "    8888888888888888 "<<endl;
            i = -(1-pow((double)2,double(i-1)));
            num -= i;
            unsigned j = 1;
        //    cout<<"num  "<<num<<endl;
            for(i = 0; i < num-1; ++ i)
            {
                j += 2;
            //    cout<<j<<" ";
            }
        //    cout<<endl;
            cout<<j<<endl;
        }
    }
    
    unsigned fun(unsigned num)
    {
        unsigned i = 0;
        unsigned sum;
        sum = -(1-pow((double)2,(double)(i-1)));
        while(sum < num)
        {
            ++ i;
            sum = -(1-pow((double)2,double(i-1)));
        }
        return i-1;
    }

    关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。 

    技术网站地址: vmfor.com

  • 相关阅读:
    C# 调用外部程序Process类
    Wix学习整理(1)——快速入门HelloWorld
    InstallShield修改XML配置文件
    小公式
    EOJ11月月赛
    长春
    贪心[偏序+treap]
    哈希
    莫比乌斯反演
    Android 编程规范
  • 原文地址:https://www.cnblogs.com/gavinsp/p/4566547.html
Copyright © 2011-2022 走看看