結果

問題 No.2189 六平方和
ユーザー titiatitia
提出日時 2023-01-13 22:20:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 10,648 KB
実行使用メモリ 8,924 KB
最終ジャッジ日時 2023-08-26 04:04:31
合計ジャッジ時間 2,037 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,784 KB
testcase_01 AC 15 ms
8,784 KB
testcase_02 AC 16 ms
8,800 KB
testcase_03 AC 17 ms
8,868 KB
testcase_04 AC 17 ms
8,788 KB
testcase_05 AC 21 ms
8,724 KB
testcase_06 AC 16 ms
8,856 KB
testcase_07 AC 15 ms
8,900 KB
testcase_08 AC 16 ms
8,740 KB
testcase_09 AC 16 ms
8,732 KB
testcase_10 AC 15 ms
8,908 KB
testcase_11 AC 16 ms
8,724 KB
testcase_12 AC 16 ms
8,896 KB
testcase_13 AC 16 ms
8,856 KB
testcase_14 AC 15 ms
8,812 KB
testcase_15 AC 17 ms
8,872 KB
testcase_16 AC 16 ms
8,872 KB
testcase_17 AC 15 ms
8,740 KB
testcase_18 AC 15 ms
8,728 KB
testcase_19 AC 15 ms
8,720 KB
testcase_20 AC 15 ms
8,748 KB
testcase_21 AC 16 ms
8,788 KB
testcase_22 AC 16 ms
8,740 KB
testcase_23 AC 17 ms
8,764 KB
testcase_24 AC 16 ms
8,876 KB
testcase_25 AC 15 ms
8,800 KB
testcase_26 AC 16 ms
8,924 KB
testcase_27 AC 15 ms
8,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt
from random import randint

N,M,mod=map(int,input().split())
A=pow(M,N,mod)
iniA=A

while True:
    ANS=[]
    
    ANS=[randint(1,10**9)]

    A=iniA-ANS[-1]**2
    A%=mod

    while A>0:
        k=int(sqrt(A))
        if k==0:
            ANS.append(mod)
        else:
            ANS.append(k)
        A-=k*k
        A%=mod

    while len(ANS)<6:
        ANS.append(mod)

    if len(ANS)==6:
        print("YES")
        print(*ANS)
        break
0