結果
| 問題 |
No.3088 XOR = SUM
|
| コンテスト | |
| ユーザー |
学ぶマン
|
| 提出日時 | 2025-04-04 22:38:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,867 bytes |
| コンパイル時間 | 512 ms |
| コンパイル使用メモリ | 82,764 KB |
| 実行使用メモリ | 60,416 KB |
| 最終ジャッジ日時 | 2025-04-04 22:38:53 |
| 合計ジャッジ時間 | 7,426 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 TLE * 1 -- * 20 |
ソースコード
import sys, math
sys.setrecursionlimit(10**8)
sys.set_int_max_str_digits(0)
INF = 10**18
MOD = 998244353
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import product, combinations, permutations, groupby, accumulate
from heapq import heapify, heappop, heappush
def I(): return sys.stdin.readline().rstrip()
def II(): return int(sys.stdin.readline().rstrip())
def IS(): return sys.stdin.readline().rstrip().split()
def MII(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(sys.stdin.readline().rstrip())
def TII(): return tuple(map(int, sys.stdin.readline().rstrip().split()))
def LII(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LSI(): return list(map(str, sys.stdin.readline().rstrip().split()))
def GMI(): return list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
def kiriage(a, b): return (a+b-1)//b
#def check(i:int, j:int): return 0 <= i < H and 0 <= j < W
def solve2(N2:list):
M = len(N2)
X, Y = 0, 0
for i in range(M):
if N2[i] == '1':
if X >= Y:
Y += 1<<(M - 1 - i)
else:
X += 1<<(M - 1 - i)
return (X, Y)
def solve(N:int):
if N == 0:
return 0, 0
candi = []
N2 = list(format(N, 'b'))
M = len(N2)
X, Y = solve2(N2)
candi.append((X*Y, X, Y))
for i in range(M):
if N2[i] == '1':
keta = M - 1 - i
if i != 0:
sub = N2[0:i] + ['0'] + ['1']*keta
else:
sub = ['1']*keta
X, Y = solve2(sub)
candi.append((X*Y, X, Y))
candi.sort()
_, X, Y = candi[-1]
return X, Y
T = II()
ansl = []
for i in range(T):
N = II()
X, Y = solve(N)
ansl.append((X, Y))
for ans in ansl:
print(*ans)
学ぶマン