zoukankan      html  css  js  c++  java
  • ACdream 1020 The Game about KILL

    找规律。

    1
    1 3 
    1 3 5 7
    1 3 5 7 9 11 13 15

    .......

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    #include<vector>
    #include<map>
    #include<set>
    #include<queue>
    #include<stack>
    #include<iostream>
    using namespace std;
    typedef long long LL;
    const double pi=acos(-1.0);
    void File()
    {
        freopen("D:\in.txt","r",stdin);
        freopen("D:\out.txt","w",stdout);
    }
    
    const int maxn=40;
    LL a[maxn],b[maxn];
    
    int main()
    {
        a[1]=1; b[0]=0;
        for(int i=2;i<=31;i++) a[i]=2*a[i-1];
        for(int i=1;i<=31;i++) b[i]=b[i-1]+a[i];
        LL n;
    
        while(~scanf("%lld",&n))
        {
            for(int i=1;i<=31;i++)
            {
                if(b[i]<=n) continue;
                else
                {
                    LL x=n-b[i-1]; if(x==0) x=a[i-1];
                    printf("%lld
    ",1+(x-1)*2);
                    break;
                }
            }
        }
        return 0;
    }
  • 相关阅读:
    正则表达式
    抽象
    面向对象
    this关键字
    http协议
    URL
    Ajax
    PHP命名空间
    PDO
    异常
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5782033.html
Copyright © 2011-2022 走看看