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

  • 相关阅读:
    putty GB18030乱码
    iptables小复习
    编译安装 openswan-2.6.34
    Windows常用的命令
    MySql实现远程连接
    防盗链
    java判断一个类是否公共类
    oracle sql性能
    状态模式让我们远离战战兢兢
    LVM管理
  • 原文地址:https://www.cnblogs.com/gavinsp/p/4566547.html
Copyright © 2011-2022 走看看