結果
問題 | No.1262 グラフを作ろう! |
ユーザー | akakimidori |
提出日時 | 2020-10-16 22:53:07 |
言語 | Rust (1.83.0 + proconio) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,091 bytes |
コンパイル時間 | 13,052 ms |
コンパイル使用メモリ | 402,896 KB |
実行使用メモリ | 31,300 KB |
最終ジャッジ日時 | 2024-07-20 23:19:58 |
合計ジャッジ時間 | 99,988 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,113 ms
27,128 KB |
testcase_01 | AC | 884 ms
13,648 KB |
testcase_02 | AC | 1,355 ms
19,712 KB |
testcase_03 | AC | 1,278 ms
17,024 KB |
testcase_04 | AC | 100 ms
9,060 KB |
testcase_05 | AC | 661 ms
12,544 KB |
testcase_06 | AC | 58 ms
9,820 KB |
testcase_07 | AC | 119 ms
5,376 KB |
testcase_08 | AC | 862 ms
16,128 KB |
testcase_09 | AC | 855 ms
12,100 KB |
testcase_10 | AC | 622 ms
10,880 KB |
testcase_11 | AC | 814 ms
17,152 KB |
testcase_12 | AC | 1,122 ms
17,256 KB |
testcase_13 | AC | 1,235 ms
17,536 KB |
testcase_14 | AC | 490 ms
10,332 KB |
testcase_15 | AC | 667 ms
10,136 KB |
testcase_16 | AC | 865 ms
16,512 KB |
testcase_17 | AC | 816 ms
14,976 KB |
testcase_18 | AC | 1,285 ms
20,552 KB |
testcase_19 | AC | 148 ms
8,704 KB |
testcase_20 | AC | 441 ms
13,568 KB |
testcase_21 | AC | 1,405 ms
21,120 KB |
testcase_22 | AC | 53 ms
7,424 KB |
testcase_23 | AC | 714 ms
12,032 KB |
testcase_24 | AC | 879 ms
16,768 KB |
testcase_25 | AC | 96 ms
6,272 KB |
testcase_26 | AC | 207 ms
7,936 KB |
testcase_27 | AC | 505 ms
13,056 KB |
testcase_28 | AC | 442 ms
11,576 KB |
testcase_29 | AC | 283 ms
10,568 KB |
testcase_30 | AC | 423 ms
9,472 KB |
testcase_31 | AC | 1,372 ms
19,712 KB |
testcase_32 | AC | 718 ms
13,440 KB |
testcase_33 | AC | 340 ms
6,656 KB |
testcase_34 | AC | 660 ms
15,420 KB |
testcase_35 | AC | 1,110 ms
16,392 KB |
testcase_36 | AC | 351 ms
7,168 KB |
testcase_37 | AC | 1,388 ms
21,504 KB |
testcase_38 | AC | 678 ms
13,952 KB |
testcase_39 | AC | 724 ms
11,392 KB |
testcase_40 | AC | 583 ms
11,112 KB |
testcase_41 | AC | 333 ms
11,648 KB |
testcase_42 | AC | 1,194 ms
19,328 KB |
testcase_43 | AC | 506 ms
11,904 KB |
testcase_44 | AC | 657 ms
12,672 KB |
testcase_45 | AC | 1,026 ms
18,560 KB |
testcase_46 | AC | 237 ms
11,904 KB |
testcase_47 | AC | 801 ms
12,928 KB |
testcase_48 | AC | 912 ms
17,116 KB |
testcase_49 | AC | 1,355 ms
20,992 KB |
testcase_50 | AC | 1,122 ms
18,812 KB |
testcase_51 | AC | 1,012 ms
14,496 KB |
testcase_52 | AC | 340 ms
12,032 KB |
testcase_53 | AC | 216 ms
6,272 KB |
testcase_54 | AC | 1,292 ms
18,816 KB |
testcase_55 | AC | 882 ms
14,960 KB |
testcase_56 | AC | 330 ms
11,500 KB |
testcase_57 | AC | 1,543 ms
23,296 KB |
testcase_58 | AC | 1,093 ms
17,152 KB |
testcase_59 | AC | 362 ms
11,648 KB |
testcase_60 | AC | 1,467 ms
22,016 KB |
testcase_61 | AC | 546 ms
10,368 KB |
testcase_62 | AC | 1,334 ms
19,840 KB |
testcase_63 | AC | 1,344 ms
19,072 KB |
testcase_64 | AC | 803 ms
13,808 KB |
testcase_65 | AC | 198 ms
7,652 KB |
testcase_66 | AC | 532 ms
10,752 KB |
testcase_67 | AC | 355 ms
9,728 KB |
testcase_68 | AC | 199 ms
11,392 KB |
testcase_69 | AC | 429 ms
9,788 KB |
testcase_70 | AC | 1,053 ms
18,220 KB |
testcase_71 | AC | 873 ms
16,000 KB |
testcase_72 | AC | 1,188 ms
20,096 KB |
testcase_73 | AC | 1,488 ms
22,016 KB |
testcase_74 | AC | 1,279 ms
19,328 KB |
testcase_75 | AC | 1,102 ms
17,792 KB |
testcase_76 | AC | 873 ms
15,360 KB |
testcase_77 | AC | 1,140 ms
18,816 KB |
testcase_78 | AC | 1,019 ms
17,408 KB |
testcase_79 | AC | 1,323 ms
22,016 KB |
testcase_80 | AC | 902 ms
17,664 KB |
testcase_81 | AC | 1,175 ms
18,432 KB |
testcase_82 | AC | 1,460 ms
21,504 KB |
testcase_83 | AC | 919 ms
17,220 KB |
testcase_84 | AC | 834 ms
15,744 KB |
testcase_85 | AC | 1,436 ms
23,040 KB |
testcase_86 | AC | 1,166 ms
18,816 KB |
testcase_87 | AC | 1,311 ms
21,504 KB |
testcase_88 | AC | 1,135 ms
18,304 KB |
testcase_89 | AC | 775 ms
16,384 KB |
testcase_90 | AC | 235 ms
24,576 KB |
testcase_91 | AC | 233 ms
24,448 KB |
testcase_92 | AC | 259 ms
24,448 KB |
testcase_93 | AC | 2,399 ms
25,472 KB |
testcase_94 | TLE | - |
testcase_95 | -- | - |
ソースコード
// ---------- begin input macro ---------- // reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::<Vec<char>>() }; ($iter:expr, bytes) => { read_value!($iter, String).bytes().collect::<Vec<u8>>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } // ---------- end input macro ---------- fn run() { input! { n: usize, m: usize, a: [usize; m], } let w = n; let mut f = (0..=w).collect::<Vec<_>>(); for i in 2..=w { if i * i > w { break; } if i == f[i] { for j in i..=(w / i) { f[j * i] = i; } } } let mut ans = 0; for a in a { let mut d = vec![1]; let mut b = a; while b > 1 { let p = f[b]; let mut c = 0; while b % p == 0 { b /= p; c += 1; } let len = d.len(); let mut mul = 1; for _ in 0..c { mul *= p; for i in 0..len { let v = d[i] * mul; d.push(v); } } } d.sort(); let mut sum = vec![0; d.len()]; for (s, d) in sum.iter_mut().zip(d.iter()) { *s = a / *d; } let mut b = a; while b > 1 { let p = f[b]; while b % p == 0 { b /= p; } let mut j = 0; for i in 0..d.len() { if d[i] * p > a { break; } if a / d[i] % p != 0 { continue; } while d[i] * p != d[j] { j += 1; } sum[i] -= sum[j]; } } for (d, s) in d.iter().zip(sum.iter()) { ans += ((a - 1) % *d) * *s; } } println!("{}", ans); } fn main() { run(); }