結果

問題 No.1514 Squared Matching
ユーザー koba-e964koba-e964
提出日時 2021-10-25 19:48:38
言語 Rust
(1.77.0)
結果
MLE  
実行時間 -
コード長 1,028 bytes
コンパイル時間 4,209 ms
コンパイル使用メモリ 159,628 KB
実行使用メモリ 783,160 KB
最終ジャッジ日時 2024-04-14 16:13:16
合計ジャッジ時間 17,845 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 MLE -
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 10 ms
13,596 KB
testcase_07 AC 127 ms
150,892 KB
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 AC 131 ms
158,084 KB
testcase_23 AC 262 ms
314,332 KB
testcase_24 AC 397 ms
470,584 KB
testcase_25 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn get_word() -> String {
    let stdin = std::io::stdin();
    let mut stdin=stdin.lock();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn main() {
    let n: usize = get();
    let mut repr = vec![0; n + 1];
    for i in 1..7100 {
        for j in 1..n / i / i + 1 {
            repr[j * i * i] = j;
        }
    }
    let mut f = vec![0i64; n + 1];
    for i in 1..n + 1 {
        f[repr[i]] += 1;
    }
    let mut ans = 0i64;
    for i in 1..n + 1 {
        ans += f[i] * f[i];
    }
    println!("{}", ans);
}
0