結果

問題 No.64 XORフィボナッチ数列
ユーザー soujikisoujiki
提出日時 2015-04-29 18:46:54
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,212 bytes
コンパイル時間 3,673 ms
コンパイル使用メモリ 74,288 KB
実行使用メモリ 57,880 KB
最終ジャッジ日時 2023-09-19 04:08:03
合計ジャッジ時間 7,342 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,516 KB
testcase_01 AC 127 ms
55,500 KB
testcase_02 AC 127 ms
55,552 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 126 ms
55,608 KB
testcase_13 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Yukicoder_64{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int[] num = new int[100];
		num[0] = 1;
		for(int i=1;i<100;i++){
			num[i] = num[i-1]*2;
		}
		int F_0 = stdIn.nextInt();
		int F_1 = stdIn.nextInt();
		int N = stdIn.nextInt();
		int 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++){
				int f0 = F_0;
				int 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);
		}
	}
}
0