結果

問題 No.434 占い
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-04-20 23:43:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 707 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 167,136 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-27 03:56:52
合計ジャッジ時間 3,473 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)





int sol(string S) {
    vector<int> v;
    for (char c : S) v.push_back(c - '0');
    int sm = 0;
    for (int i : v) sm += i;
    if (sm == 0) return 0;

    int c = 1;
    int res = 0;
    int n = v.size();
    rep(i, 0, n) {
        res += v[i] * c;
        res %= 9;
        c = c * (n - 1 - i) / (i + 1);
    }
    if (res == 0) res = 9;
    return res;
}
//-----------------------------------------------------------------------------------
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int T; cin >> T;
    rep(t, 0, T) {
        string s; cin >> s;
        printf("%d\n", sol(s));
    }
}
0