結果

問題 No.64 XORフィボナッチ数列
ユーザー C_kumoC_kumo
提出日時 2019-01-21 20:51:37
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 490 bytes
コンパイル時間 2,057 ms
コンパイル使用メモリ 28,560 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-13 17:20:04
合計ジャッジ時間 904 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 0 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 0 ms
4,352 KB
testcase_07 AC 0 ms
4,352 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 0 ms
4,368 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	long long f0,f1,n,a,b,c,ans;
	char i;
	scanf("%lld %lld %lld",&f0,&f1,&n);

	ans = 0;
	for (i=0;i<63;i++) {
		a = 1ll << i;
		b = f0 & a;
		c = f1 & a;
		if        (b==0 && c==0) {
			ans += 0;
		} else if (b==0 && c>0) {
			ans += (1ll<<i) * ((n%3==0)?0:1);
		} else if (b>0 && c==0) {
			ans += (1ll<<i) * ((n%3==1)?0:1);
		} else if (b>0 && c>0) {
			ans += (1ll<<i) * ((n%3==2)?0:1);
		}
	}
	printf("%lld\n",ans);

	return 0;
}
0