結果

問題 No.1595 The Final Digit
コンテスト
ユーザー lanegue
提出日時 2021-07-14 15:44:35
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 1 ms / 2,000 ms
+ 27µs
コード長 361 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 298 ms
コンパイル使用メモリ 76,160 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-27 02:23:03
合計ジャッジ時間 1,583 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import std.stdio;
import std.conv;
import std.string;
void main(){
	auto l=readln.split.to!(long[]);
	auto k=l[3];
	auto a=new int[1000];
	auto x=l[0]%10*100+l[1]%10*10+l[2]%10;
	auto n=4;
	a[x]=n;
	while(n<k){
		x*=10;
		x+=(x/1000+x/100+x/10)%10;
		x%=1000;
		n+=1;
		if(a[x]!=int.init){
			k=n+(k-n)%(n-a[x]);
		}
		a[x]=n;
	}
	writeln((x/100+x/10+x)%10);
}
0