結果

問題 No.1595 The Final Digit
ユーザー bal4ubal4u
提出日時 2021-08-11 20:10:14
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 459 bytes
コンパイル時間 1,242 ms
コンパイル使用メモリ 29,008 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-25 22:16:06
合計ジャッジ時間 5,178 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// yuki 1595 The Final Digit
// 2021.8.11

#include <stdio.h>

typedef long long ll;
int a[1000];

int main() {
	int p, q, r, s, t, f;
	ll K;
	scanf("%d%d%d%lld", &p, &q, &r, &K);
	p %= 10, t = p;
	q %= 10, t = t*10 + q;
	r %= 10, t = t*10 + r;
	K -= 3, f = 1;
	while (K) {
		if (f && a[t]) {
			K %= (a[t] - (int)K);
			f = 0;
		}
		a[t] = (int)K;
		s = (p+q+r) % 10;
		p = q, q = r, r = s;
		t = (t*10 + s) % 1000;
		K--;
	}
	printf("%d\n", s);
	return 0;
}
0