diff --git a/.common/rust/.gitignore b/.common/rust/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.common/rust/.gitignore @@ -0,0 +1 @@ +/target diff --git a/.common/rust/Cargo.lock b/.common/rust/Cargo.lock new file mode 100644 index 0000000..96e9370 --- /dev/null +++ b/.common/rust/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Codeforces" +version = "0.1.0" diff --git a/.common/rust/Cargo.toml b/.common/rust/Cargo.toml new file mode 100644 index 0000000..c54bb7a --- /dev/null +++ b/.common/rust/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "Codeforces" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/.common/rust/init.sh b/.common/rust/init.sh new file mode 100644 index 0000000..348499e --- /dev/null +++ b/.common/rust/init.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +for TASK in a b c d e f g h; +do + cp src/main.rs src/bin/$TASK.rs; +done; + diff --git a/.common/rust/src/bin/.gitkeep b/.common/rust/src/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.common/rust/src/main.rs b/.common/rust/src/main.rs new file mode 100644 index 0000000..4f9b0c2 --- /dev/null +++ b/.common/rust/src/main.rs @@ -0,0 +1,119 @@ +use self::math::*; +use self::output::*; +use self::input::*; + +fn solve(s: &mut Scanner) { + todo!() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn example_1() { + assert_eq!(1, 2); + } +} + +// region runner +const SINGLE_TEST: bool = false; +fn main() { + let mut s = Scanner::new(); + + if SINGLE_TEST { + solve(&mut s) + } else { + let N = s.next::(); + for _ in 0..N { + solve(&mut s) + } + } +} +// endregion runner + +mod math { + const MOD: i64 = 1_000_000_007; + + pub fn add(a: i64, b: i64) -> i64 { + (a + b) % MOD + } + + pub fn sub(a: i64, b: i64) -> i64 { + ((a - b) % MOD + MOD) % MOD + } + + pub fn mul(a: i64, b: i64) -> i64 { + (a * b) % MOD + } + + pub fn exp(b: i64, e: i64) -> i64 { + if e == 0 { + return 1; + } + + let half = exp(b, e / 2); + if e % 2 == 0 { + return mul(half, half); + } + + return mul(half, mul(half, b)); + } +} + +mod output { + pub fn yes() { + println!("YES"); + } + + pub fn no() { + println!("NO"); + } + + pub fn yesno(ans: bool) { + println!("{}", if ans { "YES" } else { "NO" }); + } +} + +mod input { + use std::collections::VecDeque; + use std::io; + use std::str::FromStr; + + pub struct Scanner { + buffer: VecDeque, + } + + impl Scanner { + pub fn new() -> Scanner { + Scanner { + buffer: VecDeque::new(), + } + } + + pub fn next(&mut self) -> T { + if self.buffer.len() == 0 { + let mut input = String::new(); + + io::stdin().read_line(&mut input).ok(); + + for word in input.split_whitespace() { + self.buffer.push_back(word.to_string()) + } + } + + let front = self.buffer.pop_front().unwrap(); + front.parse::().ok().unwrap() + } + + pub fn next_vec(&mut self, n: usize) -> Vec { + let mut arr = vec![]; + + for _ in 0..n { + arr.push(self.next::()); + } + + arr + } + } +} diff --git a/.gitignore b/.gitignore index 4f6ac96..927fb39 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,10 @@ # Kotlin !*.kt +# Rust +!.common/rust/** +!*.rs + # Don't ignore skeletons in .common, but do all others **/skeleton* -!.common/**/skeleton* \ No newline at end of file +!.common/**/skeleton*