zoukankan      html  css  js  c++  java
  • CF-Contest339-614

    614A-Link/Cut Tree

    比较水,注意64位int仍然可能溢出。

    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    
    using namespace std;
    
    typedef unsigned long long int LL;
    
    LL l,r;
    int k;
    
    int main()
    {
        scanf("%I64d %I64d %d",&l,&r,&k);
        int cnt = 0;
        LL pow = 1;
        int i = 0;
        while(true)
        {
            if(pow <=r && pow >=l)
            {
                printf("%s%I64d",cnt?" ":"",pow);
                cnt++;
            }
            i++;
            if(pow > r) break;
            if(r/k < pow) break;
            pow *= k;
        }
        if(cnt == 0) printf("-1
    ");
    }

    614B-Gena's Code

    很水,统计0的个数就好了

    区分beautiful和非beautiful数。

    #include <cstdio>
    #include <cstring>
    
    using namespace std;
    
    int N,n0;
    char unbtf[100100];
    
    int main()
    {
        scanf("%d",&N);
        int flag_unb = 0;
        int flag_0 = 0;
        getchar();
    
        for(int i=0;i<N;i++)
        {
            char c;
            int cnt = 0,flag = 1,tmp0 = 0;
            while((c=getchar()) && c>='0' && c<='9')
            {
                if(!flag_unb) unbtf[cnt] = c;
                if((c!='0'&&cnt!=0) || (c!='1'&&c!='0'&&cnt==0))
                {
                    flag = 0;
                }
                if(c == '0') tmp0++;
                cnt++;
            }
            if(!flag_unb) unbtf[cnt] = '';
            if(cnt == 1 && tmp0 == 1) flag_0 = 1;
            if(flag&&cnt>1) n0 += tmp0;
            else if(!flag)flag_unb = 1;
        }
    
        if(flag_0)
        {
            printf("0
    ");
            return 0;
        }
    
        if(flag_unb) printf("%s",unbtf);
        else printf("1");
        for(int i=0;i<n0;i++)
            printf("0");
        printf("
    ");
    }
  • 相关阅读:
    柔性数组成员 (flexible array member)-C99-ZZ
    如何阅读 Redis 源码?ZZ
    linux下网络编程学习——入门实例ZZ
    leetcode Ch2-Dynamic Programming [2014]
    leetcode Ch1-search 2014
    Skip List & Bloom Filter
    指针的引用-ZZ
    leetcode-sudoku solver
    rest framework之过滤组件
    rest framework之渲染器
  • 原文地址:https://www.cnblogs.com/helica/p/5167898.html
Copyright © 2011-2022 走看看