結果

問題 No.434 占い
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2016-10-15 00:13:39
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,684 bytes
コンパイル時間 922 ms
コンパイル使用メモリ 92,928 KB
実行使用メモリ 11,404 KB
最終ジャッジ日時 2024-05-02 00:01:37
合計ジャッジ時間 5,017 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
10,624 KB
testcase_01 AC 4 ms
5,376 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 5 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 6 ms
5,376 KB
testcase_07 AC 5 ms
5,376 KB
testcase_08 AC 125 ms
5,376 KB
testcase_09 AC 14 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 19 ms
5,376 KB
testcase_13 AC 124 ms
5,376 KB
testcase_14 AC 14 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 #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[10000];

int main() {
	rep(i, 0, 10) {
		rep(j, 0, 10) {
			rep(k, 0, 10) {
				rep(l, 0, 10) {
					ll a = i * 1000 + j * 100 + k * 10 + l;
					vector<ll> v;
					v.pb(i);
					v.pb(j);
					v.pb(k);
					v.pb(l);
					while (1) {
						if (v.sz == 1)break;
						vector<ll> v1;
						rep(j, 0, v.sz - 1) {
							ll a = v[j] + v[j + 1];
							v1.pb(a % 10 + a / 10);
						}
						v = v1;
					}
					d[a] = v[0];
				}
			}
		}
	}
	ll T;
	cin >> T;
	rep(t, 0, T) {
		string s;
		cin >> s;
		vector<ll> v;
		rep(i, 0, s.sz) {
			v.pb(s[i] - '0');
		}
		while (1) {
			if (v.sz < 4)break;
			vector<ll> v1;
			ll a = v[0] * 1000 + v[1] * 100 + v[2] * 10 + v[3];
			v1.pb(d[a]);
			rep(i, 4, v.sz) {
				a = (a % 1000) * 10 + v[i];
				v1.pb(d[a]);
			}
			v = v1;
		}
		while (1) {
			if (v.sz == 1)break;
			vector<ll> v1;
			rep(j, 0, v.sz - 1) {
				ll a = v[j] + v[j + 1];
				v1.pb(a % 10 + a / 10);
			}
			v = v1;
		}
		cout << v[0] << endl;
	}
	return 0;
}
0