結果
| 問題 |
No.434 占い
|
| コンテスト | |
| ユーザー |
kei
|
| 提出日時 | 2016-10-15 00:06:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 909 bytes |
| コンパイル時間 | 884 ms |
| コンパイル使用メモリ | 94,432 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2024-11-22 08:18:54 |
| 合計ジャッジ時間 | 4,618 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 RE * 19 |
ソースコード
#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;
}
kei