結果

問題 No.1644 Eight Digits
ユーザー 👑 tatt61880tatt61880
提出日時 2021-08-13 23:42:07
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 11 ms / 1,000 ms
コード長 808 bytes
コンパイル時間 2,825 ms
コンパイル使用メモリ 146,436 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 21:02:54
合計ジャッジ時間 3,920 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,812 KB
testcase_01 AC 11 ms
6,812 KB
testcase_02 AC 11 ms
6,940 KB
testcase_03 AC 11 ms
6,940 KB
testcase_04 AC 10 ms
6,940 KB
testcase_05 AC 10 ms
6,944 KB
testcase_06 AC 11 ms
6,944 KB
testcase_07 AC 11 ms
6,944 KB
testcase_08 AC 11 ms
6,940 KB
testcase_09 AC 11 ms
6,940 KB
testcase_10 AC 11 ms
6,944 KB
testcase_11 AC 10 ms
6,940 KB
testcase_12 AC 11 ms
6,944 KB
testcase_13 AC 11 ms
6,944 KB
testcase_14 AC 10 ms
6,940 KB
testcase_15 AC 11 ms
6,944 KB
testcase_16 AC 11 ms
6,944 KB
testcase_17 AC 11 ms
6,944 KB
testcase_18 AC 10 ms
6,944 KB
testcase_19 AC 11 ms
6,940 KB
testcase_20 AC 10 ms
6,940 KB
testcase_21 AC 10 ms
6,944 KB
testcase_22 AC 10 ms
6,944 KB
testcase_23 AC 10 ms
6,944 KB
testcase_24 AC 11 ms
6,944 KB
testcase_25 AC 10 ms
6,944 KB
testcase_26 AC 11 ms
6,940 KB
testcase_27 AC 10 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var k: int :: cui@inputInt()
	var array: []char :: "12345678"
	var ans: int :: 0
	while(@permutationNext(array), skip)
		do ans :+ array.toInt(&) % k = 0 ?(1, 0)
	end while
	
	do cui@print("\{ans}\n")
end func

func permutationNext(array: []char): bool
	var left: int :: ^array - 2
	while(left >= 0 & array[left] >= array[left + 1])
		do left :- 1
	end while
	if(left < 0)
		do array.reverse()
		ret false
	end if
	var right: int :: ^array - 1
	while(array[left] >= array[right])
		do right :- 1
	end while
	var tmp: char :: array[left]
	do array[left] :: array[right]
	do array[right] :: tmp
	do left :+ 1
	do right :: ^array - 1
	while(left < right)
		do tmp :: array[left]
		do array[left] :: array[right]
		do array[right] :: tmp
		do left :+ 1
		do right :- 1
	end while
	ret true
end func
0