結果
| 問題 |
No.434 占い
|
| コンテスト | |
| ユーザー |
はまやんはまやん
|
| 提出日時 | 2017-04-20 23:43:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 707 bytes |
| コンパイル時間 | 1,629 ms |
| コンパイル使用メモリ | 169,984 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-19 21:19:53 |
| 合計ジャッジ時間 | 3,459 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 WA * 18 |
ソースコード
#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));
}
}
はまやんはまやん