結果

問題 No.2784 繰り上がりなし十進和
ユーザー GOTKAKO
提出日時 2024-06-14 22:11:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 538 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 2,382 ms
コンパイル使用メモリ 207,192 KB
最終ジャッジ日時 2025-02-21 22:04:24
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    set<int> S;
    for(int i=0; i<6; i++){
        string s; cin >> s;
        int x = stoi(s);
        S.insert(x);
    }
    
    vector<bool> already(1000000);
    already.at(0) = true;
    queue<int> Q; Q.push(0);
    int answer = 0;
    while(Q.size()){
        int pos = Q.front(); Q.pop();
        answer++;
        for(auto s : S){
            int x = pos,y = s;
            string st = "";
            for(int k=0; k<6; k++){
                int a = x%10+y%10;
                a %= 10;
                st += '0'+a;
                x /= 10,y /= 10;
            }
            reverse(st.begin(),st.end());
            int next = stoi(st);
            if(!already.at(next)) already.at(next) = true,Q.push(next); 
        }
    }
    cout << answer << endl;

}
0