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,

    点一下,卡一年

  • 相关阅读:
    javaweb一
    javaweb三、JDBC访问数据库
    Java学习笔记十
    socket qt基础版本
    QT+VS+添加console 解决方案
    QT创建TCP Socket通信
    左值引用与右值引用
    STL 中 map和set的区别
    C++中STL哈希表介绍
    虚函数总结
  • 原文地址:https://www.cnblogs.com/ling-zhi/p/11753984.html
Copyright © 2011-2022 走看看