結果
| 問題 |
No.64 XORフィボナッチ数列
|
| コンテスト | |
| ユーザー |
toshiro_yanagi
|
| 提出日時 | 2018-06-01 11:15:57 |
| 言語 | Nim (2.2.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 753 bytes |
| コンパイル時間 | 4,068 ms |
| コンパイル使用メモリ | 66,816 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 08:47:42 |
| 合計ジャッジ時間 | 4,672 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 |
ソースコード
import strutils, sequtils, math
proc tBin(i: int): string =
var bf = i
var w = ""
while bf != 0:
w = int(bf mod 2 != 0).repr & w
bf = bf div 2
result = w
proc xOR0(x0: string, y0: string): string =
var x, y: string
y = align(y0, max(x0.len, y0.len), '0')
x = align(x0, max(x0.len, y0.len), '0')
result = ""
for i in 0 ..< x.len:
if ($x[i]).parseInt + ($y[i]).parseInt == 1:
result.add('1')
else:
result.add('0')
proc rpr(s: string): int =
for i, v in s:
if $v == $1:
result += 2 ^ (s.high - i)
let ris = stdin.readLine.split.map(parseInt)
let (f0, f1, n) = (ris[0], ris[1], ris[2])
let f2 = xOR0(f0.tBin, f1.tBin).rpr
case n mod 3:
of 0: echo f0
of 1: echo f1
of 2: echo f2
else: discard
toshiro_yanagi