結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー nonon
提出日時 2023-12-02 18:59:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 727 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 194,036 KB
最終ジャッジ日時 2025-02-18 06:12:35
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 RE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll T,M;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>T;
    for(;T--;)
    {
        cin>>M;
        vector<int>d(10,0);
        for(int i=1;i<=9;i++)cin>>d[i];
        ll ans=0;
        for(int i=1;i<=9;i++)
        {
            for(int j=0;j<d[i];j++)
            {
                ans*=10;
                ans+=i;
            }
        }
        assert(ans<=1e9);
        ans*=1e9;
        ans+=(M-ans%M);
        assert(ans<=1e18);
        assert(ans%M==0);
        cout << ans << endl;
        while(ans)
        {
            d[ans%10]--;
            ans/=10;
        }
        for(int i=1;i<=9;i++)assert(d[i]<=0);
    }
}
0