結果

問題 No.434 占い
ユーザー keikei
提出日時 2016-10-14 23:02:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 858 bytes
コンパイル時間 891 ms
コンパイル使用メモリ 94,624 KB
実行使用メモリ 10,652 KB
最終ジャッジ日時 2024-05-02 00:40:07
合計ジャッジ時間 5,524 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
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 AC 389 ms
5,376 KB
testcase_09 AC 41 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 15 ms
5,376 KB
testcase_13 AC 348 ms
5,376 KB
testcase_14 AC 41 ms
5,376 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

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>
using namespace std;

int check(string s) {
	string t;
	if (s.length() == 1) {
		return s[0] - '0';
	}
	do {
		for (int i = 0; i < s.length() - 1;i++) {
			int x = ((s[i] - '0') + (s[i + 1] - '0'));
			if (x < 10) {
				t += (x + '0');
			}
			else {
				t += (1 + x % 10 + '0');
			}
		}
		if (t.length() == 1) { return t[0] - '0'; }
		s = t;
		t.clear();
	} while (1);
}

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];
		//cout << check(S[i]) << endl;
	}
	for (int i = 0; i < T;i++) {
		cout << check(S[i]) << endl;
	}
	return 0;
}
0