Skip to content

Commit 3e9f4b8

Browse files
committed
practice with rust
1 parent 436eb38 commit 3e9f4b8

File tree

6 files changed

+99
-2
lines changed

6 files changed

+99
-2
lines changed

Diff for: atcoder/abc/abc301-400/abc336/a.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use proconio::input;
2+
3+
fn main() {
4+
input! {
5+
n: usize,
6+
}
7+
8+
let mut ans = String::new();
9+
10+
ans.push_str("L");
11+
for i in 0..n {
12+
ans.push_str("o");
13+
}
14+
ans.push_str("ng");
15+
16+
println!("{}", ans);
17+
}

Diff for: atcoder/abc/abc301-400/abc336/b.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use proconio::input;
2+
3+
fn ctz(mut x: u32) -> u32 {
4+
let mut res = 0;
5+
while x & 1 == 0 {
6+
x >>= 1;
7+
res += 1;
8+
}
9+
res
10+
}
11+
12+
fn main() {
13+
input! {
14+
n: u32,
15+
}
16+
17+
println!("{}", ctz(n));
18+
}

Diff for: atcoder/abc/abc301-400/abc336/c.rs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use proconio::input;
2+
3+
fn decimal_to_quinary(mut decimal: u64) -> String {
4+
if decimal == 0 {
5+
return String::from("0");
6+
}
7+
8+
let mut result = String::new();
9+
10+
while decimal > 0 {
11+
let remainder = decimal % 5;
12+
result = remainder.to_string() + &result; // 数字を文字列に変換して前に追加
13+
decimal /= 5;
14+
}
15+
16+
result
17+
}
18+
19+
fn main() {
20+
input! {
21+
n: u64,
22+
}
23+
let mut x = decimal_to_quinary(n - 1);
24+
25+
x = x.replace("4", "8");
26+
x = x.replace("3", "6");
27+
x = x.replace("2", "4");
28+
x = x.replace("1", "2");
29+
30+
println!("{}", x);
31+
}

Diff for: atcoder/abc/abc301-400/abc336/d.rs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use proconio::input;
2+
3+
fn decimal_to_quinary(mut decimal: u64) -> String {
4+
if decimal == 0 {
5+
return String::from("0");
6+
}
7+
8+
let mut result = String::new();
9+
10+
while decimal > 0 {
11+
let remainder = decimal % 5;
12+
result = remainder.to_string() + &result; // 数字を文字列に変換して前に追加
13+
decimal /= 5;
14+
}
15+
16+
result
17+
}
18+
19+
fn main() {
20+
input! {
21+
n: u64,
22+
}
23+
let mut x = decimal_to_quinary(n - 1);
24+
25+
x = x.replace("4", "8");
26+
x = x.replace("3", "6");
27+
x = x.replace("2", "4");
28+
x = x.replace("1", "2");
29+
30+
println!("{}", x);
31+
}

Diff for: dockerfiles/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ RUN add-apt-repository -y ppa:pypy/ppa &&\
5252
RUN rm -f /usr/bin/python && ln -s /usr/bin/python3 /usr/bin/python
5353

5454
# Rust
55-
ENV RUST_VERSION 1.66.1
55+
ENV RUST_VERSION 1.70.0
5656
ENV RUST_HOME /home/${UNAME}/.cargo
5757
ENV RUSTUP_HOME ${RUST_HOME}/rustup
5858
ENV CARGO_HOME ${RUST_HOME}/cargo

Diff for: makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test: run-test
1111
# requier `docker login` before push
1212

1313
build-atcoder:
14-
docker build --build-arg UID=$(shell id -u) --build-arg UNAME=$(shell whoami) -t $(ATCODER_IMAGE) -f dockerfiles/python.Dockerfile .
14+
docker build --build-arg UID=$(shell id -u) --build-arg UNAME=$(shell whoami) -t $(ATCODER_IMAGE) -f dockerfiles/Dockerfile .
1515
docker push $(ATCODER_IMAGE)
1616

1717
ifeq ($(shell docker ps -a --format '{{.Names}}'| grep $(ATCODER_CONTAINER_NAME)),)

0 commit comments

Comments
 (0)