Skip to content

Commit

Permalink
Add atcoder/abc328/a.rs atcoder/abc328/remain.txt atcoder/abc329/a.rs…
Browse files Browse the repository at this point in the history
… atcoder/abc329/remain.txt atcoder/abc346/a.rs atcoder/abc346/b.rs atcoder/abc346/c.rs atcoder/abc346/remain.txt
  • Loading branch information
koba-e964 committed Apr 26, 2024
1 parent 9efb913 commit fbc76c7
Show file tree
Hide file tree
Showing 8 changed files with 205 additions and 0 deletions.
37 changes: 37 additions & 0 deletions atcoder/abc328/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::io::Read;

fn get_word() -> String {
let stdin = std::io::stdin();
let mut stdin=stdin.lock();
let mut u8b: [u8; 1] = [0];
loop {
let mut buf: Vec<u8> = Vec::with_capacity(16);
loop {
let res = stdin.read(&mut u8b);
if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
break;
} else {
buf.push(u8b[0]);
}
}
if buf.len() >= 1 {
let ret = String::from_utf8(buf).unwrap();
return ret;
}
}
}

fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn main() {
let n: i32 = get();
let x: i32 = get();
let mut ans = 0;
for _ in 0..n {
let s: i32 = get();
if s <= x {
ans += s;
}
}
println!("{}", ans);
}
6 changes: 6 additions & 0 deletions atcoder/abc328/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
b
c
d
e
f
g
11 changes: 11 additions & 0 deletions atcoder/abc329/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok().unwrap();
ret
}

fn main() {
for c in getline().chars() {
print!("{} ", c);
}
}
6 changes: 6 additions & 0 deletions atcoder/abc329/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
b
c
d
e
f
g
53 changes: 53 additions & 0 deletions atcoder/abc346/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
($($r:tt)*) => {
let stdin = std::io::stdin();
let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
let mut next = move || -> String{
bytes.by_ref().map(|r|r.unwrap() as char)
.skip_while(|c|c.is_whitespace())
.take_while(|c|!c.is_whitespace())
.collect()
};
input_inner!{next, $($r)*}
};
}

macro_rules! input_inner {
($next:expr) => {};
($next:expr,) => {};
($next:expr, $var:ident : $t:tt $($r:tt)*) => {
let $var = read_value!($next, $t);
input_inner!{$next $($r)*}
};
}

macro_rules! read_value {
($next:expr, [ $t:tt ; $len:expr ]) => {
(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
};
($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

fn main() {
let out = std::io::stdout();
let mut out = BufWriter::new(out.lock());
macro_rules! puts {($($format:tt)*) => (let _ = write!(out,$($format)*););}
macro_rules! putvec {
($v:expr) => {
for i in 0..$v.len() {
puts!("{}{}", $v[i], if i + 1 == $v.len() {"\n"} else {" "});
}
}
}
input! {
n: usize,
a: [i32; n],
}
let mut b = vec![0; n - 1];
for i in 0..n - 1 {
b[i] = a[i + 1] * a[i];
}
putvec!(b);
}
43 changes: 43 additions & 0 deletions atcoder/abc346/b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use std::io::Read;

fn get_word() -> String {
let stdin = std::io::stdin();
let mut stdin=stdin.lock();
let mut u8b: [u8; 1] = [0];
loop {
let mut buf: Vec<u8> = Vec::with_capacity(16);
loop {
let res = stdin.read(&mut u8b);
if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
break;
} else {
buf.push(u8b[0]);
}
}
if buf.len() >= 1 {
let ret = String::from_utf8(buf).unwrap();
return ret;
}
}
}

fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn main() {
let w: i32 = get();
let b: i32 = get();
let c = b"wbwbwwbwbwbw";
for i in 0..12 {
let mut ww = 0;
for j in 0..w + b {
if c[(j + i) as usize % 12] == b'w' {
ww += 1;
}
}
if ww == w {
println!("Yes");
return;
}
}
println!("No");
}
45 changes: 45 additions & 0 deletions atcoder/abc346/c.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
($($r:tt)*) => {
let stdin = std::io::stdin();
let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
let mut next = move || -> String{
bytes.by_ref().map(|r|r.unwrap() as char)
.skip_while(|c|c.is_whitespace())
.take_while(|c|!c.is_whitespace())
.collect()
};
input_inner!{next, $($r)*}
};
}

macro_rules! input_inner {
($next:expr) => {};
($next:expr,) => {};
($next:expr, $var:ident : $t:tt $($r:tt)*) => {
let $var = read_value!($next, $t);
input_inner!{$next $($r)*}
};
}

macro_rules! read_value {
($next:expr, [ $t:tt ; $len:expr ]) => {
(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
};
($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

fn main() {
input! {
n: usize, k: i64,
a: [i64; n],
}
let mut hs = std::collections::HashSet::new();
for a in a {
if a <= k {
hs.insert(a);
}
}
let sum = hs.iter().sum::<i64>();
println!("{}", k * (k + 1) / 2 - sum);
}
4 changes: 4 additions & 0 deletions atcoder/abc346/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
d
e
f
g

0 comments on commit fbc76c7

Please sign in to comment.