結果

問題 No.434 占い
ユーザー keikei
提出日時 2016-10-15 00:07:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 933 bytes
コンパイル時間 860 ms
コンパイル使用メモリ 94,328 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2024-05-01 23:55:17
合計ジャッジ時間 4,082 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 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 1 ms
5,376 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 15 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 18 ms
5,376 KB
testcase_20 AC 128 ms
6,272 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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;

long long fac(long long x) {
	if (x <= 1)return 1;
	else return x*fac(x - 1);
}

int check(string s) {
	int n = s.length() - 1;
	long long sum = 0;
	long long 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;
}
0