結果

問題 No.434 占い
ユーザー keikei
提出日時 2016-10-14 23:44:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 974 bytes
コンパイル時間 948 ms
コンパイル使用メモリ 99,952 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2024-05-01 23:11:18
合計ジャッジ時間 5,907 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,656 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 561 ms
5,376 KB
testcase_09 AC 58 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 16 ms
5,376 KB
testcase_13 AC 551 ms
5,376 KB
testcase_14 AC 57 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>
#include<queue>
using namespace std;

int check(string s) {
	int f1, f2;
	queue<int> q;
	for (int i = 0; i < s.length();i++) {
		q.push(s[i] - '0');
	}
	int size = q.size();

	while (q.size() != 1) {
		//cout << q.size() << endl;
		if (size == 1) {
			q.pop();
			size = q.size();
			if (size == 1) break;
		}
		f1 = q.front(); q.pop();
		f2 = q.front();
		//cout << f1 << " " << f2 << " " << endl;
		if (f1 + f2 < 10) {
			q.push(f1 + f2);
		}
		else {
			q.push(1 + (f1 + f2) % 10);
		}
		size--;
	}
	return q.front();
}

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