結果

問題 No.1665 quotient replace
ユーザー Moss_LocalMoss_Local
提出日時 2021-09-03 21:48:08
言語 Rust
(1.77.0 + proconio)
結果
AC  
実行時間 249 ms / 3,000 ms
コード長 7,434 bytes
コンパイル時間 12,385 ms
コンパイル使用メモリ 379,732 KB
実行使用メモリ 26,504 KB
最終ジャッジ日時 2024-05-09 03:06:41
合計ジャッジ時間 17,846 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
10,752 KB
testcase_01 AC 16 ms
10,752 KB
testcase_02 AC 16 ms
10,752 KB
testcase_03 AC 16 ms
10,752 KB
testcase_04 AC 16 ms
10,752 KB
testcase_05 AC 17 ms
10,752 KB
testcase_06 AC 17 ms
10,880 KB
testcase_07 AC 16 ms
10,752 KB
testcase_08 AC 18 ms
11,008 KB
testcase_09 AC 22 ms
11,120 KB
testcase_10 AC 94 ms
15,952 KB
testcase_11 AC 193 ms
22,564 KB
testcase_12 AC 35 ms
12,028 KB
testcase_13 AC 249 ms
26,504 KB
testcase_14 AC 243 ms
26,248 KB
testcase_15 AC 242 ms
26,376 KB
testcase_16 AC 237 ms
26,380 KB
testcase_17 AC 244 ms
26,328 KB
testcase_18 AC 16 ms
10,752 KB
testcase_19 AC 16 ms
10,624 KB
testcase_20 AC 16 ms
10,752 KB
testcase_21 AC 16 ms
10,752 KB
testcase_22 AC 16 ms
10,752 KB
testcase_23 AC 16 ms
10,752 KB
testcase_24 AC 21 ms
10,752 KB
testcase_25 AC 15 ms
10,752 KB
testcase_26 AC 16 ms
10,880 KB
testcase_27 AC 18 ms
10,880 KB
testcase_28 AC 19 ms
11,136 KB
testcase_29 AC 24 ms
11,800 KB
testcase_30 AC 72 ms
18,820 KB
testcase_31 AC 100 ms
22,980 KB
testcase_32 AC 172 ms
22,044 KB
testcase_33 AC 77 ms
15,176 KB
testcase_34 AC 150 ms
20,932 KB
testcase_35 AC 135 ms
20,152 KB
testcase_36 AC 141 ms
20,500 KB
testcase_37 AC 131 ms
18,684 KB
testcase_38 AC 154 ms
20,400 KB
testcase_39 AC 111 ms
17,412 KB
testcase_40 AC 113 ms
17,412 KB
testcase_41 AC 112 ms
17,540 KB
testcase_42 AC 16 ms
10,752 KB
testcase_43 AC 17 ms
10,752 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unnecessary parentheses around type
   --> src/main.rs:117:15
    |
117 | fn readi() -> (i64) {
    |               ^   ^
    |
    = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
    |
117 - fn readi() -> (i64) {
117 + fn readi() -> i64 {
    |

warning: variable does not need to be mutable
   --> src/main.rs:260:13
    |
260 |         let mut p = table[xx];
    |             ----^
    |             |
    |             help: remove this `mut`
    |
    = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
   --> src/main.rs:285:9
    |
285 |     let mut vec: Vec<usize> = read_vec();
    |         ----^^^
    |         |
    |         help: remove this `mut`

ソースコード

diff #

// -*- coding:utf-8-unix -*-
// #![feature(map_first_last)]
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::collections::*;
use std::convert::*;
use std::convert::{From, Into};
use std::f64::consts::PI;
use std::fmt::Debug;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::marker::Copy;
use std::mem::*;
use std::ops::Bound::*;
use std::ops::{Add, Mul, Neg, Sub};
use std::str;
use std::vec;
use std::{cmp, process::Output};
use std::{cmp::Ordering, env::consts::DLL_PREFIX};
const INF: i64 = 1223372036854775807;
const UINF: usize = INF as usize;
const FINF: f64 = 122337203685.0;
const INF128: i128 = 1223372036854775807000000000000;
const LINF: i64 = 2147483647;
// const MOD: i64 = 1000000007;
const MOD: i64 = 998244353;
const T: bool = true;
const F: bool = false;

const MPI: f64 = 3.14159265358979323846264338327950288f64;
// const MOD: i64 = INF;

const UMOD: usize = MOD as usize;
use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;

macro_rules! p {
    ($x:expr) => {
        println!("{}", $x);
    };
}
macro_rules! d {
    ($x:expr) => {
        println!("{:?}", $x);
    };
}
macro_rules! dd {
    (x:expr) => {
        dbg!(x);
    };
}

macro_rules! chmin {
    ($base:expr, $($cmps:expr),+ $(,)*) => {{
        let cmp_min = min!($($cmps),+);
        if $base > cmp_min {
            $base = cmp_min;
            true
        } else {
            false
        }
    }};
}

macro_rules! chmax {
    ($base:expr, $($cmps:expr),+ $(,)*) => {{
        let cmp_max = max!($($cmps),+);
        if $base < cmp_max {
            $base = cmp_max;
            true
        } else {
            false
        }
    }};
}

macro_rules! min {
    ($a:expr $(,)*) => {{
        $a
    }};
    ($a:expr, $b:expr $(,)*) => {{
        std::cmp::min($a, $b)
    }};
    ($a:expr, $($rest:expr),+ $(,)*) => {{
        std::cmp::min($a, min!($($rest),+))
    }};
}

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),+))
    }};
}

// use str::Chars;

// use str::Chars;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn readi() -> (i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    iter.next().unwrap().parse::<i64>().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}

fn readff() -> (f64, f64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<f64>().unwrap(),
        iter.next().unwrap().parse::<f64>().unwrap(),
    )
}

#[allow(dead_code)]
fn readiii() -> (i64, i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

fn readcc() -> (char, char) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<char>().unwrap(),
        iter.next().unwrap().parse::<char>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuu() -> (usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuuu() -> (usize, usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

fn readiiii() -> (i64, i64, i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}

fn prime_table_min(n: usize) -> Vec<usize> {
    let mut is_prime = vec![true; n + 1];
    let mut res = vec![0 as usize; n + 1];

    for i in 0..=n {
        res[i] = i;
    }

    let mut i = 2 as usize;
    while i * i <= n {
        if !is_prime[i] {
            i += 1;
            continue;
        }
        // println!("{:?}", "call");
        // is_prime[i] = i;

        let mut j = i + i as usize;
        while j <= n {
            is_prime[j] = false;
            res[j] = min(res[j], i);
            j += i;
        }
        i += 1;
    }

    return res;
}

fn prime_factorization_osak(x: usize, table: &Vec<usize>) -> BTreeMap<usize, usize> {
    let mut res: BTreeMap<usize, usize> = BTreeMap::new();
    let mut xx = x;
    // let mut p: usize = 2;
    while xx > 1 {
        let mut p = table[xx];
        let t = res.get_mut(&p);
        if t.is_none() {
            res.insert(p, 1);
        } else {
            *t.unwrap() += 1;
        }
        xx /= table[xx];

        // println!("{:?} {:?}", p, res);
        // p += 1;
    }

    if xx != 1 {
        let t = res.get_mut(&xx);
        if t.is_none() {
            res.insert(xx, 1);
        } else {
            *t.unwrap() += 1;
        }
    }
    res
}
fn solve() {
    let n: usize = read();
    let mut vec: Vec<usize> = read_vec();
    let mut data = vec![0; n];
    let pt = prime_table_min(1010100);
    for i in 0..n {
        let t = prime_factorization_osak(vec[i], &pt);
        let mut x = 0;
        for i in t {
            x += i.1;
        }
        data[i] = x;
    }
    let mut xored = 0;
    for i in 0..n {
        xored ^= data[i];
    }
    if xored != 0 {
        println!("white");
    } else {
        println!("black");
    }
    return;
}

fn main() {
    solve();
}
0