• 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,

    点一下,卡一年

  • 相关阅读:
    Berry Jam(前缀后>差值,贪心)
    Privatization of Roads in Treeland (贪心+染色)
    主席树
    C 语言是一门抽象的、面向过程的语言,C 语言广泛应用于底层开发
    限流中间件AspNetCoreRateLimit
    远程调试 Visual Studio2022
    高并发下秒杀
    设计模式的分类和六大原则
    MySQL的锁机制
    代码是怎么运行
  • 原文地址:https://www.cnblogs.com/ling-zhi/p/11753984.html
Copyright © 2020-2023  润新知