結果

問題 No.432 占い(Easy)
ユーザー ふーらくたる
提出日時 2016-10-14 22:33:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 62,268 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-22 07:23:10
合計ジャッジ時間 1,374 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int t;
    cin >> t;

    while (t--) {
        string str;
        cin >> str;
        vector<int> s(str.size()), s2(str.size());
        for (int i = 0; i < str.size(); i++) {
            s[i] = str[i] - '0';
        }

        for (int i = 0; i < s.size() - 1; i++) {
            for (int j = 0; j < s.size() - i - 1; j++) {
                s2[j] = s[j] + s[j + 1];
                if (s2[j] >= 10) {
                    s2[j] = 1 + s2[j] % 10;
                }
            }
            /*
            cout << i << "回目: ";
            for (int j = 0; j < s.size() - i - 1; j++) {
                cout << s[j] << " ";
            }
            cout << endl;
            */
            s = s2;
        }
        cout << s[0] << endl;
    }

    return 0;
}
0