zoukankan      html  css  js  c++  java
  • POJ

    https://vjudge.net/problem/POJ-3208

    The number 666 is considered to be the occult “number of the beast” and is a well used number in all major apocalypse themed blockbuster movies. However the number 666 can’t always be used in the script so numbers such as 1666 are used instead. Let us call the numbers containing at least three contiguous sixes beastly numbers. The first few beastly numbers are 666, 1666, 2666, 3666, 4666, 5666…

    Given a 1-based index n, your program should return the nth beastly number.

    就是求第n小的包含三个连续的6的数


    辣鸡poj,死活登不进

    vjudge访问速度比肩外星网站

    国内大学排名第一就可以为所欲为吗????????????????????????


    #include<iostream>
    #include<cstdio>
    
    #define ri register int
    #define u long long
    
    namespace opt {
    
        inline u in() {
            u x(0),f(1);
            char s(getchar());
            while(s<'0'||s>'9') {
                if(s=='-') f=-1;
                s=getchar();
            }
            while(s>='0'&&s<='9') {
                x=(x<<1)+(x<<3)+s-'0';
                s=getchar();
            }
            return x*f;
        }
    
    }
    
    using opt::in;
    
    #include<cstring>
    
    namespace mainstay {
    
        u f[30][4],ans[30];
    
        inline void solve() {
            u T(in());
            f[0][0]=1;
            for(ri i(1); i<=20; ++i) {
                f[i][0]=9*(f[i-1][0]+f[i-1][1]+f[i-1][2]);
                f[i][1]=f[i-1][0];
                f[i][2]=f[i-1][1];
                f[i][3]=10*f[i-1][3]+f[i-1][2];
            }
            while(T--) {
                u _a(in()),_m(1),flg(0);
                for(; f[_m][3]<_a; ++_m);
                for(ri i(_m); i>=1; --i) {
                    u _t(0);
                    for(ri j(0); j<=9; ++j) {
                        _t=f[i-1][3];
                        u _flg(0);
                        if(flg) _t+=f[i-1][0]+f[i-1][1]+f[i-1][2];
                        else if(j==6) {
                            u k(i);
                            for(; k+1<=_m&&ans[k+1]==6; ++k);
                            if(k-i>=2) _flg=1;
                            for(ri p(i); p<=k&&p-i+1<=3; ++p)
                                _t+=f[i-1][3-(p-i+1)];
                        }
                        if(_t<_a) {
                            _a-=_t;
                        } else {
                            ans[i]=j;
                            if(j==6&&_flg) flg=1;
                            std::cout<<j;
                            break;
                        }
                    }
                }
                printf("
    ");
            }
        }
    
    }
    
    
    int main() {
    
        //freopen("f.in","r",stdin);
        //freopen("f.out","w",stdout);
        mainstay::solve();
    
    }

     泥马,刚写完博客vjudge也炸了

    辣鸡vjudge,

    点一下,卡一年

  • 相关阅读:
    BZOJ 1996: [Hnoi2010]chorus 合唱队
    BZOJ 2431: [HAOI2009]逆序对数列
    BZOJ1013: [JSOI2008]球形空间产生器sphere
    BZOJ 4196: [Noi2015]软件包管理器
    BZOJ 3670: [Noi2014]动物园
    NOIP 2017 提高组 day1t2 时间复杂度
    loj #6278. 数列分块入门 2
    CF285 E Positions in Permutations——“恰好->大于”的容斥和允许“随意放”的dp
    洛谷 1969 积木大赛——水题
    洛谷 1965 转圈游戏——水题
  • 原文地址:https://www.cnblogs.com/ling-zhi/p/11753984.html
Copyright © 2011-2022 走看看