結果
問題 | No.64 XORフィボナッチ数列 |
ユーザー | chiho_miyako |
提出日時 | 2015-04-11 22:04:36 |
言語 | Java21 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,916 bytes |
コンパイル時間 | 2,688 ms |
コンパイル使用メモリ | 74,228 KB |
実行使用メモリ | 57,780 KB |
最終ジャッジ日時 | 2023-09-17 19:18:27 |
合計ジャッジ時間 | 5,329 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
55,872 KB |
testcase_01 | AC | 126 ms
56,356 KB |
testcase_02 | AC | 123 ms
55,520 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 | 123 ms
56,052 KB |
testcase_13 | RE | - |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner koko = new Scanner(System.in); int zero = koko.nextInt(); int one = koko.nextInt(); int n = koko.nextInt(); if(n%3==0){ System.out.println(zero); }else if(n%3==1){ System.out.println(one); }else{ String tz = Integer.toBinaryString(zero); String to = Integer.toBinaryString(one); int min = Math.min(tz.length(),to.length()); int max = Math.max(tz.length(),to.length()); char[] ans = new char[max]; if(tz.length()>to.length()){ for(int i=0; i<min; i++){ if(tz.charAt(max-1-i)==to.charAt(min-1-i)){ ans[max-1-i] = '0'; }else{ ans[max-1-i] = '1'; } } for(int i=0; i<max-min; i++){ ans[i] = tz.charAt(i); } }else if(tz.length()<to.length()){ for(int i=0; i<min; i++){ if(tz.charAt(min-1-i)==to.charAt(max-1-i)){ ans[max-1-i] = '0'; }else{ ans[max-1-i] = '1'; } } for(int i=0; i<max-min; i++){ ans[i] = to.charAt(i); } }else{ for(int i=0; i<min; i++){ if(tz.charAt(min-1-i)==to.charAt(max-1-i)){ ans[max-1-i] = '0'; }else{ ans[max-1-i] = '1'; } } } String an = String.valueOf(ans); int a = Integer.parseInt(an,2); System.out.println(a); } } }