結果
問題 | No.2929 Miracle Branch |
ユーザー |
![]() |
提出日時 | 2024-11-15 16:06:31 |
言語 | Swift (6.0.3) |
結果 |
AC
|
実行時間 | 151 ms / 2,000 ms |
コード長 | 721 bytes |
コンパイル時間 | 12,052 ms |
コンパイル使用メモリ | 127,032 KB |
実行使用メモリ | 15,232 KB |
最終ジャッジ日時 | 2024-11-15 16:06:53 |
合計ジャッジ時間 | 15,183 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
var x = Int(readLine()!)! var pr = [Int](), n = -1 while x % 4 == 0{ x /= 4 pr.append(4) } for i in 2...200000{ while x % i == 0{ x /= i pr.append(i) } } if x == 1{ if pr.count == 0{ pr.append(1) } let s = pr.reduce(0,+) if s+pr.count <= 200000{ n = s+pr.count } } let k = pr.count print(n) if n != -1{ if k >= 2{ for i in 1..<k{ print("\(i) \(i+1)") } } var l = k+1 for i in 1...k{ for j in l..<l+pr[i-1]{ print("\(i) \(j)") } l = l + pr[i-1] } let c = [String](repeating:"b",count:k) + [String](repeating:"g",count:n-k) let nc = c.joined(separator:" ") print(nc) }