結果

問題 No.432 占い(Easy)
ユーザー kimiyukikimiyuki
提出日時 2016-10-14 23:22:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,145 bytes
コンパイル時間 968 ms
コンパイル使用メモリ 74,872 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2023-08-14 12:58:06
合計ジャッジ時間 2,943 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 5 ms
7,328 KB
testcase_13 AC 5 ms
7,300 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 6 ms
7,300 KB
testcase_18 AC 3 ms
4,448 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <typename T, typename X> auto vectors(T a, X x) { return vector<T>(x, a); }
template <typename T, typename X, typename Y, typename... Zs> auto vectors(T a, X x, Y y, Zs... zs) { auto cont = vectors(a, y, zs...); return vector<decltype(cont)>(x, cont); }
int main() {
    int t; cin >> t;
    vector<string> s(t); repeat (i,t) cin >> s[i];
    int n_max = 0; repeat (i,t) setmax<int>(n_max, s[i].length());
    vector<vector<int> > choose = vectors(int(), n_max+1, n_max+1);
    choose[1][0] = 1;
    repeat_from (n,1,n_max) {
        repeat (r,n+1+1) {
            choose[n+1][r] = (choose[n][r] + (r-1 >= 0 ? choose[n][r-1] : 0)) % 9;
        }
    }
    repeat (i,t) {
        int n = s[i].length();
        int acc = 0;
        repeat (j,n) acc += (s[i][j] - '0') * choose[n][j];
        while (acc >= 10) acc = acc / 10 + acc % 10;
        cout << acc << endl;
    }
    return 0;
}
0