結果

問題 No.2007 Arbitrary Mod (Easy)
ユーザー SarievoSarievo
提出日時 2023-05-23 14:57:06
言語 Rust
(1.77.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 5,366 bytes
コンパイル時間 15,271 ms
コンパイル使用メモリ 377,696 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 02:49:01
合計ジャッジ時間 17,813 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,248 KB
testcase_04 AC 1 ms
5,248 KB
testcase_05 AC 1 ms
5,248 KB
testcase_06 AC 1 ms
5,248 KB
testcase_07 AC 1 ms
5,248 KB
testcase_08 AC 1 ms
5,248 KB
testcase_09 AC 1 ms
5,248 KB
testcase_10 AC 1 ms
5,248 KB
testcase_11 AC 1 ms
5,248 KB
testcase_12 AC 1 ms
5,248 KB
testcase_13 AC 1 ms
5,248 KB
testcase_14 AC 1 ms
5,248 KB
testcase_15 AC 1 ms
5,248 KB
testcase_16 AC 1 ms
5,248 KB
testcase_17 AC 1 ms
5,248 KB
testcase_18 AC 1 ms
5,248 KB
testcase_19 AC 1 ms
5,248 KB
testcase_20 AC 1 ms
5,248 KB
testcase_21 AC 1 ms
5,248 KB
testcase_22 AC 1 ms
5,248 KB
testcase_23 AC 1 ms
5,248 KB
testcase_24 AC 1 ms
5,248 KB
testcase_25 AC 1 ms
5,248 KB
testcase_26 AC 1 ms
5,248 KB
testcase_27 AC 1 ms
5,248 KB
testcase_28 AC 1 ms
5,248 KB
testcase_29 AC 1 ms
5,248 KB
testcase_30 AC 1 ms
5,248 KB
testcase_31 AC 1 ms
5,248 KB
testcase_32 AC 1 ms
5,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::collections::HashSet`
 --> src/main.rs:1:5
  |
1 | use std::collections::HashSet;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused macro definition: `map`
 --> src/main.rs:5:14
  |
5 | macro_rules! map { () => { ::std::collections::HashMap::new() }; ($($key: expr => $value: expr),+ $(,)?) => {{ const CAP: usize = $crate:...
  |              ^^^
  |
  = note: `#[warn(unused_macros)]` on by default

warning: unused macro definition: `set`
 --> src/main.rs:6:14
  |
6 | macro_rules! set { () => { ::std::collections::HashSet::new() }; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($elem...
  |              ^^^

warning: unused macro definition: `btmap`
 --> src/main.rs:7:14
  |
7 | macro_rules! btmap { () => { ::std::collections::BTreeMap::new() }; ($($key: expr => $value: expr),+ $(,)?) => {{ let mut map = ::std::co...
  |              ^^^^^

warning: unused macro definition: `btset`
 --> src/main.rs:8:14
  |
8 | macro_rules! btset { () => { ::std::collections::BTreeSet::new() }; ($($elem: expr),+ $(,)?) => {{ let mut set = ::std::collections::BTre...
  |              ^^^^^

warning: unused macro definition: `deque`
 --> src/main.rs:9:14
  |
9 | macro_rules! deque { () => { ::std::collections::VecDeque::new() }; ($elem: expr; $n: expr) => {{ let mut deque = ::std::collections::Vec...
  |              ^^^^^

warning: unused macro definition: `bheap`
  --> src/main.rs:10:14
   |
10 | macro_rules! bheap { () => { ::std::collections::BinaryHeap::new() }; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($(...
   |              ^^^^^

warning: unused macro definition: `cvec`
  --> src/main.rs:19:14
   |
19 | macro_rules! cvec { ($($tokens: tt)+) => { $crate::c![$($tokens)+].collect::<::std::vec::Vec<_>>() }; }
   |              ^^^^

warning: unused macro definition: `cmap`
  --> src/main.rs:20:14
   |
20 | macro_rules! cmap { ($key:expr => $value:expr; $(

ソースコード

diff #

use std::collections::HashSet;
// Copyright (c) 2023 Sarievo
// https://github.com/GrayJack/sugars/blob/dev/LICENSE
#[macro_export] macro_rules! count { (@subst $($x: tt)*) => (()); ($($rest: expr),*) => (<[()]>::len(&[$($crate::count!(@subst $rest)),*])); }
macro_rules! map { () => { ::std::collections::HashMap::new() }; ($($key: expr => $value: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($key),*); let mut map = ::std::collections::HashMap::with_capacity(CAP); $(let _ = map.insert($key, $value);)+map }}; }
macro_rules! set { () => { ::std::collections::HashSet::new() }; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($elem),*); let mut set = ::std::collections::HashSet::with_capacity(CAP); $(let _ = set.insert($elem);)+set }}; }
macro_rules! btmap { () => { ::std::collections::BTreeMap::new() }; ($($key: expr => $value: expr),+ $(,)?) => {{ let mut map = ::std::collections::BTreeMap::new(); $(let _ = map.insert($key, $value);)+map }}; }
macro_rules! btset { () => { ::std::collections::BTreeSet::new() }; ($($elem: expr),+ $(,)?) => {{ let mut set = ::std::collections::BTreeSet::new(); $(set.insert($elem);)+set }}; }
macro_rules! deque { () => { ::std::collections::VecDeque::new() }; ($elem: expr; $n: expr) => {{ let mut deque = ::std::collections::VecDeque::new(); deque.resize_with($n, || $elem);deque }}; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($elem),*); let mut deque = ::std::collections::VecDeque::with_capacity(CAP); $(deque.push_back($elem);)+deque }}; }
macro_rules! bheap { () => { ::std::collections::BinaryHeap::new() }; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($elem),*); let mut bheap = ::std::collections::BinaryHeap::with_capacity(CAP); $(bheap.push($elem);)+bheap }} }
#[macro_export] macro_rules! c {
    ($e:expr; $i:pat in $iter:expr) => { $iter.map(|$i| $e) };
    ($e:expr; $i:pat in $iter:expr, if $cond:expr) => {{ $iter.filter(|$i| $cond).map(|$i| $e) }};
    ($e:expr; $i1:pat in $iter1:expr, $i2:pat in $iter2:expr) => {{ $iter1.flat_map(|$i1| $iter2.map(move |$i2| $e)) }};
    ($e:expr; $i1:pat in $iter1:expr, $i2:pat in $iter2:expr, if $cond:expr) => {{ $iter1.flat_map(|$i1| $iter2.filter_map(move |$i2| if $cond { Some($e) } else { None })) }};
    ($e:expr; $i1:pat in $iter1:expr, $i2:pat in $iter2:expr, $i3:pat in $iter3:expr) => {{ $iter1.flat_map(|$i1| $iter2.flat_map(move |$i2| $iter3.map(move |$i3| $e))) }};
    ($e:expr; $i1:pat in $iter1:expr, $i2:pat in $iter2:expr, $i3:pat in $iter3:expr, if $cond:expr) => {{ $iter1.flat_map(|$i1| { $iter2.flat_map(move |$i2| { $iter3.filter_map(move |$i3| if $cond { Some($e) } else { None }) }) }) }};
}
macro_rules! cvec { ($($tokens: tt)+) => { $crate::c![$($tokens)+].collect::<::std::vec::Vec<_>>() }; }
macro_rules! cmap { ($key:expr => $value:expr; $($tokens: tt)+) => {{ $crate::c![ ($key, $value); $($tokens)+ ].collect::<::std::collections::HashMap<_, _>>() }}; }
macro_rules! cset { ($($tokens: tt)+) => {{ $crate::c![$($tokens)+].collect::<::std::collections::HashSet<_>>() }}; }
macro_rules! cbtmap { ($key:expr => $value:expr; $($tokens: tt)+) => {{ $crate::c![ ($key, $value); $($tokens)+ ].collect::<::std::collections::BTreeMap<_, _>>() }}; }
macro_rules! cbtset { ($($tokens: tt)+) => {{ $crate::c![$($tokens)+].collect::<::std::collections::BTreeSet<_>>() }}; }
macro_rules! cdeque { ($($tokens: tt)+) => {{ use std::collections::VecDeque; $crate::c![$($tokens)+].collect::<::std::collections::VecDeque<_>>() }}; }
macro_rules! cbheap { ($($tokens: tt)+) => {{ use std::collections::BinaryHeap; $crate::c![$($tokens)+].collect::<::std::collections::BinaryHeap<_>>() }}; }

const DX: [i32; 8] = [0, 1, 0, -1, 1, 1, -1, -1];
const DY: [i32; 8] = [1, 0, -1, 0, 1, -1, -1, 1];

fn pow(x: i64, t: i64, m: i64) -> i64 {
    let mut x = x;
    let mut ret = 1;
    let mut rem = t;
    while rem != 0 {
        if (rem & 1) == 1 { ret = (ret * x) % m; }
        x = (x * x) % m;
        rem >>= 1;
    }
    return ret;
}

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let a: i64 = sc.read();
    let n: i64 = sc.read();
    let m: i64 = 998244353;
    let ret = pow(a, n, m);
    println!("{}", m);
    println!("{}", ret);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self { Self(r, std::io::BufWriter::new(w)) }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.0.by_ref().bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }.parse().ok().expect("Parse error.")
    }
    pub fn chars(&mut self) -> Vec<char> { self.read::<String>().chars().collect() }
    pub fn usize0(&mut self) -> usize { self.read::<usize>() - 1 }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
}
0