結果
問題 | No.434 占い |
ユーザー | kei |
提出日時 | 2016-10-15 00:06:22 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 909 bytes |
コンパイル時間 | 722 ms |
コンパイル使用メモリ | 96,168 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-05-01 23:54:38 |
合計ジャッジ時間 | 4,177 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | RE | - |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 3 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 14 ms
5,376 KB |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | AC | 17 ms
5,376 KB |
testcase_20 | AC | 124 ms
6,400 KB |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | AC | 1 ms
5,376 KB |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
ソースコード
#define _USE_MATH_DEFINES #include<stdio.h> #include<string> #include<iostream> #include<cctype> #include<cstdio> #include<vector> #include<stack> #include<algorithm> #include<math.h> #include<set> #include<map> #include<iomanip> #include<queue> using namespace std; int fac(int x) { if (x <= 1)return 1; else return x*fac(x - 1); } int check(string s) { int n = s.length() - 1; int sum = 0; int Ans; for (int i = 0; i <= n;i++) { //cout << fac(n) << " " << fac(i) << " " << fac(n)/fac(i) << endl; sum += (fac(n) / (fac(i)*fac(n - i))*(s[i] - '0')); //cout << sum << endl; } Ans = (sum % 10) + sum / 10; while (Ans >= 10) { Ans = Ans % 10 + Ans / 10; } return Ans; } int main() { cin.tie(0); ios::sync_with_stdio(false); int T; cin >> T; vector<string> S(T); for (int i = 0; i < T; i++) { cin >> S[i]; } for (int i = 0; i < T;i++) { cout << check(S[i]) << endl; } return 0; }