結果

問題 No.1233 割り切れない気持ち
ユーザー o2co2c
提出日時 2020-09-20 22:10:18
言語 Rust
(1.77.0)
結果
AC  
実行時間 25 ms / 3,153 ms
コード長 2,595 bytes
コンパイル時間 978 ms
コンパイル使用メモリ 158,084 KB
実行使用メモリ 6,840 KB
最終ジャッジ日時 2023-09-06 16:34:58
合計ジャッジ時間 3,502 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
5,060 KB
testcase_01 AC 15 ms
5,080 KB
testcase_02 AC 15 ms
5,064 KB
testcase_03 AC 15 ms
5,124 KB
testcase_04 AC 15 ms
5,128 KB
testcase_05 AC 15 ms
5,084 KB
testcase_06 AC 14 ms
5,120 KB
testcase_07 AC 17 ms
5,612 KB
testcase_08 AC 18 ms
5,924 KB
testcase_09 AC 23 ms
6,228 KB
testcase_10 AC 23 ms
6,440 KB
testcase_11 AC 17 ms
5,524 KB
testcase_12 AC 24 ms
6,616 KB
testcase_13 AC 25 ms
6,556 KB
testcase_14 AC 25 ms
6,604 KB
testcase_15 AC 25 ms
6,520 KB
testcase_16 AC 25 ms
6,588 KB
testcase_17 AC 21 ms
6,620 KB
testcase_18 AC 23 ms
6,520 KB
testcase_19 AC 24 ms
6,412 KB
testcase_20 AC 21 ms
6,628 KB
testcase_21 AC 22 ms
6,644 KB
testcase_22 AC 22 ms
6,592 KB
testcase_23 AC 22 ms
6,624 KB
testcase_24 AC 23 ms
6,588 KB
testcase_25 AC 22 ms
6,568 KB
testcase_26 AC 22 ms
6,612 KB
testcase_27 AC 22 ms
6,584 KB
testcase_28 AC 23 ms
6,840 KB
testcase_29 AC 22 ms
6,752 KB
testcase_30 AC 23 ms
6,712 KB
testcase_31 AC 22 ms
6,616 KB
testcase_32 AC 22 ms
6,556 KB
testcase_33 AC 22 ms
6,556 KB
testcase_34 AC 22 ms
6,576 KB
testcase_35 AC 22 ms
6,724 KB
testcase_36 AC 23 ms
6,788 KB
testcase_37 AC 15 ms
5,120 KB
testcase_38 AC 21 ms
6,592 KB
testcase_39 AC 22 ms
6,620 KB
testcase_40 AC 21 ms
6,544 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable does not need to be mutable
  --> Main.rs:14:338
   |
14 | ...es !read {($($t :tt ) ,*;$n :expr ) =>{{let stdin =::std ::io ::stdin () ;let ret =::std ::io ::BufRead ::lines (stdin .lock () ) .take ($n ) .map (|line |{let line =line .unwrap () ;let mut it =line .split_whitespace () ;_read !(it ;$($t ) ,*) } ) .collect ::<Vec <_ >>() ;ret } } ;($($t :tt ) ,*) =>{{let line =readln () ;let mut it =l...
   |                                                                                                                                                                                                                                                                                                                                            ----^^
   |                                                                                                                                                                                                                                                                                                                                            |
   |                                                                                                                                                                                                                                                                                                                                            help: remove this `mut`
...
26 | ... = read!([usize]);
   |       -------------- in this macro invocation
   |
   = note: `#[warn(unused_mut)]` on by default
   = note: this warning originates in the macro `read` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: 1 warning emitted

ソースコード

diff #

#[allow(unused_imports)]
use {std::cmp::*, std::collections::*, std::io::Write, std::ops::*};

#[allow(unused_macros)]
macro_rules! dbg { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; }

pub fn readln() -> String {
    let mut line = String::new();
    ::std::io::stdin()
        .read_line(&mut line)
        .unwrap_or_else(|e| panic!("{}", e));
    line
}
macro_rules !read {($($t :tt ) ,*;$n :expr ) =>{{let stdin =::std ::io ::stdin () ;let ret =::std ::io ::BufRead ::lines (stdin .lock () ) .take ($n ) .map (|line |{let line =line .unwrap () ;let mut it =line .split_whitespace () ;_read !(it ;$($t ) ,*) } ) .collect ::<Vec <_ >>() ;ret } } ;($($t :tt ) ,*) =>{{let line =readln () ;let mut it =line .split_whitespace () ;_read !(it ;$($t ) ,*) } } ;}
macro_rules !_read {($it :ident ;[char ] ) =>{_read !($it ;String ) .chars () .collect ::<Vec <_ >>() } ;($it :ident ;[u8 ] ) =>{Vec ::from (_read !($it ;String ) .into_bytes () ) } ;($it :ident ;usize1 ) =>{$it .next () .unwrap_or_else (||panic !("input mismatch" ) ) .parse ::<usize >() .unwrap_or_else (|e |panic !("{}" ,e ) ) -1 } ;($it :ident ;[usize1 ] ) =>{$it .map (|s |s .parse ::<usize >() .unwrap_or_else (|e |panic !("{}" ,e ) ) -1 ) .collect ::<Vec <_ >>() } ;($it :ident ;[$t :ty ] ) =>{$it .map (|s |s .parse ::<$t >() .unwrap_or_else (|e |panic !("{}" ,e ) ) ) .collect ::<Vec <_ >>() } ;($it :ident ;$t :ty ) =>{$it .next () .unwrap_or_else (||panic !("input mismatch" ) ) .parse ::<$t >() .unwrap_or_else (|e |panic !("{}" ,e ) ) } ;($it :ident ;$($t :tt ) ,+) =>{($(_read !($it ;$t ) ) ,*) } ;}

#[allow(unused_macros)]
macro_rules !max {($a :expr $(,) *) =>{{$a } } ;($a :expr ,$b :expr $(,) *) =>{{std ::cmp ::max ($a ,$b ) } } ;($a :expr ,$($rest :expr ) ,+$(,) *) =>{{std ::cmp ::max ($a ,max !($($rest ) ,+) ) } } ;}
#[allow(unused_macros)]
macro_rules !chmax {($base :expr ,$($cmps :expr ) ,+$(,) *) =>{{let cmp_max =max !($($cmps ) ,+) ;if $base <cmp_max {$base =cmp_max ;true } else {false } } } ;}

const M: usize = 200000;

fn main() {
    let n = read!(usize);
    let a = read!([usize]);

    let mut ans = n * a.iter().sum::<usize>();

    let mut b = vec![0; M + 1];
    for i in 0..n {
        b[a[i]] += 1;
    }
    for i in (0..M).rev() {
        b[i] += b[i + 1];
    }

    let mut div = vec![0; M + 1];
    for i in 1..=M {
        for j in (i..=M).step_by(i) {
            div[i] += b[j];
        }
    }

    for a in a {
        ans -= div[a] * a;
    }

    println!("{}", ans);
}
0