結果
問題 | No.2929 Miracle Branch |
ユーザー |
![]() |
提出日時 | 2024-06-15 10:17:50 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,049 bytes |
コンパイル時間 | 470 ms |
コンパイル使用メモリ | 82,524 KB |
実行使用メモリ | 63,232 KB |
最終ジャッジ日時 | 2024-06-15 10:17:55 |
合計ジャッジ時間 | 5,677 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | TLE * 1 -- * 39 |
ソースコード
def factorization(n):arr = []temp = nfor i in range(2, int(n**(1/2)+5)):if temp%i==0:cnt=0while temp%i==0:cnt+=1temp //= iarr.append([i, cnt])if temp!=1:arr.append([temp, 1])if arr==[]:arr.append([n, 1])return arrn = int(input())F = factorization(n)A = []for i in range(len(F)):if(F[i][0] == 2):for _ in range(F[i][1] // 2):A.append(4)for _ in range(F[i][1] % 2):A.append(2)else:for _ in range(F[i][1]):A.append(F[i][0])cnt = len(A) + sum(A)bl = Falsefor i in range(2,2*10**5+1):if(n%i == 0):bl = Trueif(cnt > 2*10**5 or bl==False):print(-1)exit()E = []C = [-1] * cntv = 0for i in range(len(A)):u = vC[u] = "b"for _ in range(A[i]):v += 1E.append([u+1, v+1])C[v] = "g"v += 1print(cnt)for e in E:print(*e)print(*C)