結果
| 問題 | No.747 循環小数N桁目 Hard |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-02 16:16:58 |
| 言語 | Nim (2.2.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,179 bytes |
| コンパイル時間 | 4,098 ms |
| コンパイル使用メモリ | 88,048 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-15 09:41:34 |
| 合計ジャッジ時間 | 8,325 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 120 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 18) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated] /home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'times' [UnusedImport] /home/judge/data/code/Main.nim(2, 37) Warning: imported and not used: 'deques' [UnusedImport] /home/judge/data/code/Main.nim(1, 25) Warning: imported and not used: 'sequtils' [UnusedImport] /home/judge/data/code/Main.nim(2, 44) Warning: imported and not used: 'heapqueue' [UnusedImport] /home/judge/data/code/Main.nim(2, 26) Warning: imported and not used: 'strformat' [UnusedImport] /home/judge/data/code/Main.nim(1, 52) Warning: imported and not used: 'tables' [UnusedImport] /home/judge/data/code/Main.nim(1, 60) Warning: imported and not used: 'sets' [UnusedImport] /home/judge/data/code/Main.nim(1, 66) Warning: imported and not used: 'lists' [UnusedImport] /home/judge/data/code/Main.nim(1, 73) Warning: imported and not used: 'intsets' [UnusedImport] /home/judge/data/code/Main.nim(2, 8) Warning: imported and not used: 'critbits' [UnusedImport] /home/judge/data/code/Main.nim(2, 18) Warning: imported and not used: 'future' [UnusedImport]
ソースコード
import times, strutils, sequtils, math, algorithm, tables, sets, lists, intsets
import critbits, future, strformat, deques,heapqueue
template `max=`(x,y) = x = max(x,y)
template `min=`(x,y) = x = min(x,y)
template `mod=`(x,y) = x = x mod y
template scan2 = (scan(), scan())
template scan3 = (scan(), scan())
let read* = iterator: string {.closure.} =
while true: (for s in stdin.readLine.split: yield s)
proc scan(): int = read().parseInt
proc scanf(): float = read().parseFloat
proc toInt(c:char): int =
return int(c) - int('0')
proc mod6(s:string):int=
var
s = s.reversed()
m = 1
dsum = 0
for i in 0..<s.len:
dsum+=(s[i].toInt()*m).mod(6)
m = (m*10).mod(6)
return dsum.mod(6)
#for i in 0..100000:
#if i.mod(6) != ($i).mod6:
#echo i,", ",i.mod(6), ", ", ($i).mod6
proc solve():int=
var
n = read()
k = read()
v = @[2,8,5,7,1,4]
nmod6 = n.mod6()
kmod2 = k[^1].toInt.mod(2)
if nmod6 in @[0,1,3,4]:
return v[((nmod6+5).mod(6))]
elif nmod6 == 2:
if kmod2==0:
return v[3]
else:
return v[1]
elif nmod6 == 5:
if kmod2==0:
return v[0]
else:
return v[4]
echo solve()