結果
| 問題 |
No.64 XORフィボナッチ数列
|
| コンテスト | |
| ユーザー |
soujiki
|
| 提出日時 | 2015-04-29 18:54:09 |
| 言語 | Java (openjdk 23) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,219 bytes |
| コンパイル時間 | 2,857 ms |
| コンパイル使用メモリ | 77,464 KB |
| 実行使用メモリ | 54,148 KB |
| 最終ジャッジ日時 | 2024-07-05 16:44:39 |
| 合計ジャッジ時間 | 5,077 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 RE * 10 |
ソースコード
import java.util.*;
public class Yukicoder_64{
public static void main(String[] args){
Scanner stdIn = new Scanner(System.in);
long[] num = new long[100];
num[0] = 1;
for(int i=1;i<100;i++){
num[i] = num[i-1]*2;
}
long F_0 = stdIn.nextInt();
long F_1 = stdIn.nextInt();
int N = stdIn.nextInt();
long ans = 0;
if(N==0){
System.out.println(F_0);
}
else if(N==1){
System.out.println(F_1);
}
else{
for(int j=1;j<N;j++){
long f0 = F_0;
long f1 = F_1;
int count = 0;
boolean[] judg = new boolean[100];
Arrays.fill(judg,false);
for(int i=0;i<100;i++){
if(f0<num[i]){
count = i;
}
}
for(int i=0;i<100;i++){
if(f1<num[i] && count<i){
count = i;
}
}
for(int i=count;i>=0;i--){
if(f0>=num[i] && f1<num[i]){
judg[i] = true;
f0-=num[i];
}
else if(f0<num[i] && f1>=num[i]){
judg[i] = true;
f1 -= num[i];
}
else if(f0>=num[i] && f1>=num[i]){
f0 -= num[i];
f1 -= num[i];
}
}
ans = 0;
for(int i=count;i>=0;i--){
if(judg[i]){
ans += Math.pow(2,i);
}
}
F_0 = F_1;
F_1 = ans;
}
System.out.println(ans);
}
}
}
soujiki