結果

問題 No.677 10^Nの約数
ユーザー lzy9lzy9
提出日時 2018-04-27 22:39:43
言語 Rust
(1.77.0 + proconio)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 4,987 bytes
コンパイル時間 16,547 ms
コンパイル使用メモリ 396,872 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-27 21:59:55
合計ジャッジ時間 17,446 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,812 KB
testcase_03 AC 1 ms
6,816 KB
testcase_04 AC 1 ms
6,820 KB
testcase_05 AC 1 ms
6,816 KB
testcase_06 AC 1 ms
6,820 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `k`
  --> src/main.rs:42:17
   |
42 |             for k in 0..i {
   |                 ^ help: if this is intentional, prefix it with an underscore: `_k`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `k`
  --> src/main.rs:46:17
   |
46 |             for k in 0..j {
   |                 ^ help: if this is intentional, prefix it with an underscore: `_k`

ソースコード

diff #

#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::collections::{HashMap, VecDeque};

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin_lock = stdin.lock();
    let s = stdin_lock
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

#[allow(dead_code)]
static DX: &'static [i32] = &[0, 0, 1, -1];
#[allow(dead_code)]
static DY: &'static [i32] = &[1, -1, 0, 0];
#[allow(dead_code)]
static MOD: u64 = 1000000007;

fn main() {
    let n: usize = read();

    let mut ans: Vec<u64> = Vec::new();

    for i in 0..n + 1 {
        for j in 0..n + 1 {
            let mut tp = 1u64;
            let mut fp = 1u64;

            for k in 0..i {
                tp *= 2;
            }

            for k in 0..j {
                fp *= 5;
            }

            ans.push(tp * fp);
        }
    }

    ans.sort();

    for i in ans.iter() {
        println!("{}", i);
    }
}

#[allow(dead_code)]
struct SegTree<T> where T: Clone + Copy {
    n: usize,
    dat: Vec<T>,
    operation: fn(T, T) -> T,
    default: T,
}

impl<T> SegTree<T> where T: Clone + Copy {
    #[allow(dead_code)]
    fn new(n: usize, operation: fn(T, T) -> T, default: T) -> Self {
        let mut size = 1;

        while size < n {
            size <<= 1;
        }

        SegTree {
            n: size,
            dat: vec![default; size * 2],
            operation,
            default,
        }
    }

    #[allow(dead_code)]
    fn update(&mut self, idx: usize, x: T) {
        let mut k = idx + self.n - 1;

        self.dat[k] = x;

        while 0 < k {
            k = (k - 1) / 2;

            self.dat[k] = (self.operation)(self.dat[k * 2 + 1], self.dat[k * 2 + 2]);
        }
    }

    #[allow(dead_code)]
    fn query(&self, from: usize, to: usize) -> T {
        self.query_rec(from, to, 0, 0, self.n)
    }

    #[allow(dead_code)]
    fn query_rec(&self, from: usize, to: usize, idx: usize, a: usize, b: usize) -> T {
        if b <= from || to <= a {
            return self.default;
        }

        if from <= a && b <= to {
            return self.dat[idx];
        }

        let mid = (a + b) / 2;

        (self.operation)(self.query_rec(from, to, idx * 2 + 1, a, mid), self.query_rec(from, to, idx * 2 + 2, mid, b))
    }
}

#[allow(dead_code)]
struct SCC {
    groups: Vec<Vec<usize>>,
    index: Vec<usize>,
    parent: Vec<Option<usize>>,
}

#[allow(dead_code)]
impl SCC {
    #[allow(dead_code)]
    fn new(graph: &Vec<Vec<usize>>) -> Self {
        let (groups, index, parent) = SCC::make(graph);

        SCC {
            groups,
            index,
            parent
        }
    }

    #[allow(dead_code)]
    fn make(graph: &Vec<Vec<usize>>) -> (Vec<Vec<usize>>, Vec<usize>, Vec<Option<usize>>) {
        let n = graph.len();
        let mut stack: Vec<usize> = Vec::new();
        let mut visited: Vec<bool> = vec![false; n];
        let mut parent: Vec<Option<usize>> = vec![None; n];

        let mut rgraph: Vec<Vec<usize>> = (0..n).map(|_| Vec::new()).collect();

        for i in 0..n {
            for j in graph[i].iter() {
                rgraph[*j].push(i);
            }

            if !visited[i] {
                SCC::init_dfs(graph, i, &mut stack, &mut visited, &mut parent);
            }
        }

        let mut groups: Vec<Vec<usize>> = Vec::new();
        let mut index: Vec<usize> = vec![0; n];
        let mut done: Vec<bool> = vec![false; n];
        let mut i = 0;

        while let Some(node) = stack.pop() {
            if !done[node] {
                let mut group = Vec::new();
                SCC::make_dfs(&rgraph, node, &mut done, &mut group);

                for member in group.iter() {
                    index[*member] = i;
                }

                groups.push(group);
                i += 1;
            }
        }

        (groups, index, parent)
    }

    #[allow(dead_code)]
    fn init_dfs(graph: &Vec<Vec<usize>>, current: usize, stack: &mut Vec<usize>, visited: &mut Vec<bool>, parent: &mut Vec<Option<usize>>) {
        visited[current] = true;

        for next in graph[current].iter() {
            if !visited[*next] {
                parent[*next] = Some(current);
                SCC::init_dfs(graph, *next, stack, visited, parent);
            }
        }

        stack.push(current);
    }

    #[allow(dead_code)]
    fn make_dfs(rgraph: &Vec<Vec<usize>>, current: usize, done: &mut Vec<bool>, group: &mut Vec<usize>) {
        group.push(current);
        done[current] = true;

        for next in rgraph[current].iter() {
            if !done[*next] {
                SCC::make_dfs(rgraph, *next, done, group);
            }
        }
    }
}
0