-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add atcoder/abc336/b.rs atcoder/abc336/c.rs atcoder/abc336/e.rs
- Loading branch information
Showing
4 changed files
with
136 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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 mut n: i64 = get(); | ||
let mut x = 0; | ||
while n % 2 == 0 { | ||
n /= 2; | ||
x += 1; | ||
} | ||
println!("{x}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 mut n: i64 = get(); | ||
let mut c = 1; | ||
let mut s = 0; | ||
n -= 1; | ||
while n > 0 { | ||
s += (n % 5) * c * 2; | ||
c *= 10; | ||
n /= 5; | ||
} | ||
println!("{s}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
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 f(n: [usize; 15], d: usize) -> i64 { | ||
let mut dp = vec![vec![[0i64; 2]; d]; d + 1]; | ||
dp[0][0][1] = 1; | ||
for i in 0..15 { | ||
let mut ep = vec![vec![[0i64; 2]; d]; d + 1]; | ||
for j in 0..d + 1 { | ||
for k in 0..d { | ||
for eq in 0..2 { | ||
let val = dp[j][k][eq]; | ||
for q in 0..10 { | ||
if eq == 1 && q > n[i] { | ||
break; | ||
} | ||
let neq = if eq == 1 && q == n[i] { 1 } else { 0 }; | ||
if j + q > d { | ||
continue; | ||
} | ||
ep[j + q][(10 * k + q) % d][neq] += val; | ||
} | ||
} | ||
} | ||
} | ||
dp = ep; | ||
} | ||
dp[d][0][0] + dp[d][0][1] | ||
} | ||
|
||
fn main() { | ||
let mut n: i64 = get(); | ||
let mut dig = [0; 15]; | ||
for i in 0..15 { | ||
dig[14 - i] = (n % 10) as usize; | ||
n /= 10; | ||
} | ||
let mut ans = 0; | ||
for d in 1..127 { | ||
ans += f(dig, d); | ||
} | ||
println!("{ans}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
b | ||
c | ||
d | ||
e | ||
f | ||
g |