D. Print a 1337-string...

时间:2019-08-28
本文章向大家介绍D. Print a 1337-string...,主要包括D. Print a 1337-string...使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

D. Print a 1337-string...

输出一个字符串

里面包含n个子序列 1337

#include<bits/stdc++.h>
using namespace std;
#define sc(x) scanf("%I64d",&x);
#define int long long
int t,n;
int C[100005];
void init()
{
    for(int i=1; i<=100000; i++)
    {
        C[i]=((i-1)*i)/2;
    }
}
signed main()
{
    init();
    sc(t);
    while(t--)
    {
        sc(n);
        if(n<=10000)
        {
            for(int i=0; i<n; i++)
            {
                putchar('1');
            }
            putchar('3');
            putchar('3');
            putchar('7');
            cout<<'\n';
        }
        else
        {
            int x=2,y=1,i;
            for( i=2; C[i]<=n; i++)
            {
                x=i;
            }
            y=n-(n/C[x])*C[x];
            // cout<<n<<' '<<C[x]<<'\n';
            cout<<"133";
            for(int i=0;i<y;i++){
                cout<<'7';
            }
            x-=2;
            for(int i=0;i<x;i++){
                cout<<'3';
            }
            cout<<'7'<<'\n';
        }
    }
}

原文地址:https://www.cnblogs.com/liulex/p/11423225.html