結果
| 問題 |
No.64 XORフィボナッチ数列
|
| コンテスト | |
| ユーザー |
toshiro_yanagi
|
| 提出日時 | 2018-06-01 11:08:30 |
| 言語 | Nim (2.2.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 778 bytes |
| コンパイル時間 | 4,414 ms |
| コンパイル使用メモリ | 65,592 KB |
| 実行使用メモリ | 9,628 KB |
| 最終ジャッジ日時 | 2024-06-30 08:48:04 |
| 合計ジャッジ時間 | 10,002 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 1 -- * 4 |
ソースコード
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)
var (f0, f1, n) = (ris[0], ris[1], ris[2])
case n:
of 0: echo f0
of 1: echo f1
else:
for i in 0 ..< (n - 1):
f0 = xOR0(f0.tBin, f1.tBin).rpr
swap(f0, f1)
echo f1
toshiro_yanagi