結果
| 問題 | No.3088 XOR = SUM | 
| コンテスト | |
| ユーザー |  pengin_2000 | 
| 提出日時 | 2025-04-04 22:20:21 | 
| 言語 | C (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 96 ms / 2,000 ms | 
| コード長 | 877 bytes | 
| コンパイル時間 | 1,116 ms | 
| コンパイル使用メモリ | 25,856 KB | 
| 実行使用メモリ | 7,720 KB | 
| 最終ジャッジ日時 | 2025-04-04 22:20:39 | 
| 合計ジャッジ時間 | 13,860 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge6 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 22 | 
コンパイルメッセージ
main.c: In function ‘solve’:
main.c:5:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%lld", &n);
      |         ^~~~~~~~~~~~~~~~~
main.c: In function ‘main’:
main.c:47:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   47 |         scanf("%d", &t);
      |         ^~~~~~~~~~~~~~~
            
            ソースコード
#include<stdio.h>
void solve()
{
	long long int n;
	scanf("%lld", &n);
	long long int b, x[2], y[2];
	for (b = 1; b <= n; b *= 2);
	b /= 2;
	x[0] = b;
	y[0] = (n ^ b);
	n = b - 1;
	b /= 2;
	x[1] = b;
	y[1] = (n ^ b);
	long long int res[2][4], k = 1000000000, i, j;
	for (i = 0; i < 2; i++)
	{
		res[i][0] = (x[i] % k) * (y[i] % k);
		res[i][1] = (x[i] % k) * (y[i] / k) + (x[i] / k) * (y[i] % k);
		res[i][2] = (x[i] / k) * (y[i] / k);
		res[i][3] = 0;
		for (j = 0; j < 3; j++)
		{
			res[i][j + 1] += res[i][j] / k;
			res[i][j] %= k;
		}
	}
	for (j = 3; j >= 0; j--)
	{
		if (res[0][j] > res[1][j])
		{
			printf("%lld %lld\n", x[0], y[0]);
			return;
		}
		if (res[0][j] < res[1][j])
		{
			printf("%lld %lld\n", x[1], y[1]);
			return;
		}
	}
	printf("%lld %lld\n", x[0], y[0]);
	return;
}
int main()
{
	int t;
	scanf("%d", &t);
	for (; t > 0; t--)
		solve();
	return 0;
}
            
            
            
        