結果

問題 No.1871 divisXor
ユーザー gew1fw
提出日時 2025-06-12 14:09:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,224 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 82,444 KB
実行使用メモリ 76,460 KB
最終ジャッジ日時 2025-06-12 14:11:00
合計ジャッジ時間 38,002 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def sum_divisors(x):
    if x == 0:
        return 0
    sumd = 0
    for i in range(1, int(x**0.5) + 1):
        if x % i == 0:
            if i == x // i:
                sumd += i
            else:
                sumd += i + x // i
    return sumd

def find_x(c, max_x=100000):
    x_list = []
    for x in range(1, max_x + 1):
        if sum_divisors(x) == c:
            x_list.append(x)
    return x_list

def main():
    N = int(sys.stdin.readline().strip())
    if N == 0:
        print(-1)
        return
    
    # Step 1: Check if there's x with f(x) = N
    x_list = find_x(N)
    for x in x_list:
        print(1)
        print(x)
        return
    
    # Step 2: Check for M=2: 1 and x where f(x) = a = N^1
    a = N ^ 1
    x_list_a = find_x(a)
    for x in x_list_a:
        if x != 1 and (1 + x) < 2 * N:
            print(2)
            print(1, x)
            return
    
    # Step 3: Check for M=3: 1,6, x where f(x) = c = 13 ^ N
    c = 13 ^ N
    x_list_c = find_x(c)
    for x in x_list_c:
        if x not in [1, 6] and (1 + 6 + x) < 2 * N:
            print(3)
            print(1, 6, x)
            return
    
    # If none found
    print(-1)

if __name__ == "__main__":
    main()
0