結果
問題 |
No.300 平方数
|
ユーザー |
![]() |
提出日時 | 2015-11-21 19:45:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,008 bytes |
コンパイル時間 | 92 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 11,776 KB |
最終ジャッジ日時 | 2024-09-13 17:07:38 |
合計ジャッジ時間 | 2,990 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 RE * 1 |
other | AC * 4 RE * 39 |
コンパイルメッセージ
Main.py:10: SyntaxWarning: "is" with 'int' literal. Did you mean "=="? while d is 1: Main.py:10: SyntaxWarning: "is" with 'int' literal. Did you mean "=="? while d is 1: Main.py:30: SyntaxWarning: "is not" with 'int' literal. Did you mean "!="? while n is not 1: Main.py:30: SyntaxWarning: "is not" with 'int' literal. Did you mean "!="? while n is not 1:
ソースコード
# -*- coding: utf-8 -*- import fractions def factor(n, rho): f=lambda a:(a*a+rho)%n x=2 y=2 d=1 while d is 1: x=f(x) y=f(f(y)) d=fractions.gcd(abs(x-y), n) # print("n=%d rho=%d: x=%d y=%d d=%d"%(n,rho,x,y,d)) return d def add_factor(n, lst): if (n%2)==0: d=2 else: d=factor(n,n-1) lst.append(d) return int(n/d), lst def factorint(n): """ Using Prllard's rho algorithm with Linier congruential generators. """ lst=[] while n is not 1: n, lst = add_factor(n, lst) return lst def main(): X=int(input()) factors=factorint(X) factors.sort() Y=1 prev=1 for index in range(len(factors)): # print("%d, %d"%(prev, factors[index])) if factors[index] == prev: prev=1 else: Y=Y*prev # print(" *%d=%d"%(prev, Y)) prev=factors[index] Y=Y*prev print(Y) if __name__ == '__main__': main()