結果

問題 No.2379 Burnside's Theorem
ユーザー so-heyso-hey
提出日時 2023-07-14 21:48:26
言語 Rust
(1.77.0 + proconio)
結果
WA  
実行時間 -
コード長 2,592 bytes
コンパイル時間 11,831 ms
コンパイル使用メモリ 382,972 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-16 06:43:22
合計ジャッジ時間 13,020 ms
ジャッジサーバーID
(参考情報)
judge1 / judge6
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,820 KB
testcase_02 AC 0 ms
6,940 KB
testcase_03 AC 9 ms
6,940 KB
testcase_04 WA -
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 WA -
testcase_09 AC 2 ms
6,944 KB
testcase_10 WA -
testcase_11 AC 1 ms
6,940 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 14 ms
6,940 KB
testcase_20 AC 27 ms
6,944 KB
testcase_21 AC 37 ms
6,940 KB
testcase_22 WA -
testcase_23 AC 5 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable `p` is assigned to, but never used
  --> src/main.rs:65:13
   |
65 |     let mut p = 0;
   |             ^
   |
   = note: consider using `_p` instead
   = note: `#[warn(unused_variables)]` on by default

warning: variable `q` is assigned to, but never used
  --> src/main.rs:66:13
   |
66 |     let mut q = 0;
   |             ^
   |
   = note: consider using `_q` instead

warning: variable `a` is assigned to, but never used
  --> src/main.rs:67:13
   |
67 |     let mut a = 0;
   |             ^
   |
   = note: consider using `_a` instead

warning: variable `b` is assigned to, but never used
  --> src/main.rs:68:13
   |
68 |     let mut b = 0;
   |             ^
   |
   = note: consider using `_b` instead

warning: value assigned to `p` is never read
  --> src/main.rs:79:17
   |
79 |                 p = i;
   |                 ^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` on by default

warning: value assigned to `a` is never read
  --> src/main.rs:80:17
   |
80 |                 a = cnt;
   |                 ^
   |
   = help: maybe it is overwritten before being read?

warning: value assigned to `q` is never read
  --> src/main.rs:90:29
   |
90 | ...                   q = j;
   |                       ^
   |
   = help: maybe it is overwritten before being read?

warning: value assigned to `b` is never read
  --> src/main.rs:91:29
   |
91 | ...                   b = cnt;
   |                       ^
   |
   = help: maybe it is overwritten before being read?

ソースコード

diff #

pub mod scanner {
    pub struct Scanner {
        buf: Vec<String>,
    }

    impl Scanner  {
        pub fn new() -> Self {
            Self { buf: vec![] }
        }

        pub fn new_from(source: &str) -> Self {
            let source = String::from(source);
            let buf = Self::split(source);
            Self { buf }
        }

        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            loop {
                if let Some(x) = self.buf.pop() {
                    return x.parse().ok().expect("");
                }
                let mut source = String::new();
                std::io::stdin().read_line(&mut source).expect("");
                self.buf = Self::split(source);
            }
        }

        fn split(source: String) -> Vec<String> {
            source
                .split_whitespace()
                .rev()
                .map(String::from)
                .collect::<Vec<_>>()
        }
    }
}

use crate::scanner::Scanner;

fn main() {
    let mut scanner = Scanner::new();
    let t = 1;
    for _ in 0..t {
        solve(&mut scanner);
    }
}

fn solve(scanner: &mut Scanner) {
    let n: usize = scanner.next();
    let mut m = 1;
    while (m+1) * (m+1) <= n {
        m += 1;
    }
    let mut is_prime = vec![true; m+1];
    is_prime[0] = false; is_prime[1] = false;
    for i in 2..m {
        if is_prime[i] {
            let mut j = i.pow(2);
            while j <= m {
                is_prime[j] = false;
                j += i;
            }
        }
    }
    let mut p = 0;
    let mut q = 0;
    let mut a = 0;
    let mut b = 0;
    let mut flag = false;
    for i in 2..=m {
        let mut x = n;
        if is_prime[i] {
            let mut cnt = 0;
            while x % i == 0 {
                x /= i;
                cnt += 1;
            }
            if cnt > 0 {
                p = i;
                a = cnt;
                for j in i+1..=m {
                    let mut y = x;
                    if is_prime[j] {
                        cnt = 0;
                        while y % j == 0 {
                            y /= j;
                            cnt += 1;
                        }
                        if y == 1 {
                            q = j;
                            b = cnt;
                            flag = true;
                            break;
                        }
                    }
                }
            }
        }
        if flag {
            break;
        }
    }
    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}
0