Happy Birthday (Codeforces思维➕枚举)

Happy Birthday

#include <bits/stdc++.h>
using namespace std;

const int N = 1e6+5;

int a[11];
int main()
{
    int n;
    cin>>n;
    for(int i = 0 ; i < n ; i ++)
    {
        for (int j = 0 ; j < 10 ; j ++)
            cin>>a[j];
        int flag = 0;
        for(int k = 0 ; k < N ;k ++)
        {
            if(a[0] == k-1)
            {
                cout<<1;
                for(int j = 0 ; j < k ; j ++)
                    cout<<0;
                cout<<endl;
                break;
            }
            for(int j = 1 ; j < 10 ; j ++)
            {
                if(a[j] == k)
                {
                    for(int l = 0 ; l <= k ; l ++)
                        cout<<j;
                    cout<<endl;
                    flag = 1;
                    break;
                }
            }
            if(flag) break;
        }

    }
}


发布了340 篇原创文章 · 获赞 128 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/king9666/article/details/104138718