結果

問題 No.2929 Miracle Branch
ユーザー rururunrururun
提出日時 2024-11-15 16:06:31
言語 Swift
(5.10.0)
結果
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
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
9,216 KB
testcase_01 AC 9 ms
9,216 KB
testcase_02 AC 9 ms
9,088 KB
testcase_03 AC 10 ms
9,088 KB
testcase_04 AC 10 ms
9,216 KB
testcase_05 AC 9 ms
9,216 KB
testcase_06 AC 10 ms
9,216 KB
testcase_07 AC 10 ms
9,344 KB
testcase_08 AC 10 ms
9,088 KB
testcase_09 AC 9 ms
9,216 KB
testcase_10 AC 10 ms
9,344 KB
testcase_11 AC 10 ms
9,088 KB
testcase_12 AC 10 ms
9,216 KB
testcase_13 AC 9 ms
9,216 KB
testcase_14 AC 10 ms
9,216 KB
testcase_15 AC 10 ms
9,216 KB
testcase_16 AC 10 ms
9,216 KB
testcase_17 AC 9 ms
8,960 KB
testcase_18 AC 10 ms
9,088 KB
testcase_19 AC 11 ms
9,216 KB
testcase_20 AC 12 ms
9,344 KB
testcase_21 AC 14 ms
9,240 KB
testcase_22 AC 10 ms
9,216 KB
testcase_23 AC 19 ms
9,472 KB
testcase_24 AC 44 ms
10,752 KB
testcase_25 AC 13 ms
9,344 KB
testcase_26 AC 10 ms
9,216 KB
testcase_27 AC 11 ms
9,216 KB
testcase_28 AC 11 ms
9,088 KB
testcase_29 AC 11 ms
9,088 KB
testcase_30 AC 11 ms
9,088 KB
testcase_31 AC 11 ms
9,088 KB
testcase_32 AC 11 ms
8,960 KB
testcase_33 AC 11 ms
9,088 KB
testcase_34 AC 122 ms
14,848 KB
testcase_35 AC 124 ms
15,048 KB
testcase_36 AC 10 ms
9,088 KB
testcase_37 AC 151 ms
15,104 KB
testcase_38 AC 122 ms
15,104 KB
testcase_39 AC 123 ms
15,104 KB
testcase_40 AC 124 ms
15,088 KB
testcase_41 AC 123 ms
15,104 KB
testcase_42 AC 123 ms
15,232 KB
testcase_43 AC 121 ms
15,104 KB
testcase_44 AC 123 ms
14,996 KB
testcase_45 AC 9 ms
9,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
}
0