結果

問題 No.2784 繰り上がりなし十進和
ユーザー katonyonko
提出日時 2024-06-14 22:51:51
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 836 ms / 2,000 ms
コード長 1,043 bytes
コンパイル時間 1,247 ms
コンパイル使用メモリ 118,632 KB
実行使用メモリ 66,048 KB
最終ジャッジ日時 2024-06-14 22:52:11
合計ジャッジ時間 16,373 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#include <tuple>
#include <algorithm>

using namespace std;

vector<int> mapInputToInt(const string &input) {
    vector<int> result;
    for (char ch : input) {
        result.push_back(ch - '0');
    }
    return result;
}

int main() {
    vector<vector<int>> A(6);
    string input;
    
    for (int i = 0; i < 6; ++i) {
        cin >> input;
        A[i] = mapInputToInt(input);
    }

    set<tuple<int, int, int, int, int, int>> ans;
    vector<int> p(6, 0);
    
    do {
        vector<int> sums(6, 0);
        for (int j = 0; j < 6; ++j) {
            for (int i = 0; i < 6; ++i) {
                sums[j] = (sums[j] + p[i] * A[i][j]) % 10;
            }
        }
        ans.emplace(sums[0], sums[1], sums[2], sums[3], sums[4], sums[5]);
        
        int idx = 0;
        while (idx < 6 && ++p[idx] == 10) {
            p[idx] = 0;
            ++idx;
        }
        if (idx == 6) break;
        
    } while (true);
    
    cout << ans.size() << endl;

    return 0;
}
0