提出 #39445961


ソースコード 拡げる

#[allow(unused_imports)]
use petgraph::unionfind::UnionFind;
#[allow(unused_imports)]
use proconio::{fastout, input, marker::Chars, marker::Usize1};
#[allow(unused_imports)]
use std::collections::{HashSet, VecDeque};

#[fastout]
fn main() {
    input! {
        n:usize,
    }
    //let mut set = HashSet::new();
    let mut result = 0;
    let mut list: Vec<usize> = vec![];
    let mut list2: Vec<usize> = vec![];
    let mut jd: bool = false;
    for i in 1..=(n / 2) {
        list = gen_divisors(n - i);
        list2 = gen_divisors(i);
        if n - i != i {
            result += list.len() * list2.len();
        } else {
            jd = true;
        }
    }

    result *= 2;
    if jd {
        result += list.len() * list2.len();
    }
    println!("{}", result);
}

fn gen_divisors(n: usize) -> Vec<usize> {
    let mut res = vec![];

    for i in (1..).take_while(|&x| x * x <= n) {
        if n % i == 0 {
            if i * i == n {
                res.push(i);
            } else {
                res.push(i);
                res.push(n / i);
            }
        }
    }
    res.sort();

    res
}

提出情報

提出日時
問題 C - Four Variables
ユーザ sou31415
言語 Rust (1.42.0)
得点 300
コード長 1120 Byte
結果 AC
実行時間 458 ms
メモリ 2196 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 26
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 02_large_00.txt, 02_large_01.txt, 02_large_02.txt, 02_large_03.txt, 02_large_04.txt, 02_large_05.txt, 02_large_06.txt, 02_large_07.txt, 02_large_08.txt, 02_large_09.txt, 03_rnd_00.txt, 03_rnd_01.txt, 03_rnd_02.txt, 03_rnd_03.txt, 03_rnd_04.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 7 ms 2072 KiB
00_sample_01.txt AC 2 ms 2048 KiB
00_sample_02.txt AC 28 ms 2052 KiB
01_small_00.txt AC 1 ms 2068 KiB
01_small_01.txt AC 1 ms 2104 KiB
01_small_02.txt AC 1 ms 2092 KiB
01_small_03.txt AC 1 ms 2032 KiB
01_small_04.txt AC 3 ms 2116 KiB
01_small_05.txt AC 1 ms 1936 KiB
01_small_06.txt AC 1 ms 2040 KiB
01_small_07.txt AC 1 ms 2132 KiB
02_large_00.txt AC 458 ms 2140 KiB
02_large_01.txt AC 450 ms 2152 KiB
02_large_02.txt AC 455 ms 2196 KiB
02_large_03.txt AC 451 ms 2076 KiB
02_large_04.txt AC 454 ms 2116 KiB
02_large_05.txt AC 450 ms 2096 KiB
02_large_06.txt AC 451 ms 2092 KiB
02_large_07.txt AC 449 ms 2180 KiB
02_large_08.txt AC 457 ms 2064 KiB
02_large_09.txt AC 451 ms 2140 KiB
03_rnd_00.txt AC 369 ms 2064 KiB
03_rnd_01.txt AC 119 ms 2108 KiB
03_rnd_02.txt AC 298 ms 2068 KiB
03_rnd_03.txt AC 419 ms 1992 KiB
03_rnd_04.txt AC 387 ms 2108 KiB