1
0
Fork 0
This commit is contained in:
Alex Kotov 2023-03-27 07:33:31 +04:00
parent 5303e00347
commit b3600502f7
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
5 changed files with 96 additions and 0 deletions

24
112A.rs Normal file
View File

@ -0,0 +1,24 @@
use std::cmp::Ordering;
use std::io::{self, BufRead, BufReader, Write};
fn main() {
let mut stdin = io::stdin();
let mut stdout = io::stdout();
let lines: Vec<String> =
BufReader::new(stdin)
.lines()
.map(|line| line.unwrap().to_lowercase())
.collect();
let line1 = lines[0].as_str();
let line2 = lines[1].as_str();
let result = match line1.cmp(line2) {
Ordering::Less => -1,
Ordering::Equal => 0,
Ordering::Greater => 1,
};
stdout.write_all(format!("{}\n", result).as_ref()).unwrap();
}

17
263A.rs Normal file
View File

@ -0,0 +1,17 @@
use std::io::{self, BufRead};
fn main() {
let matrix: Vec<Option<i32>> =
io::BufReader::new(io::stdin())
.lines()
.map(|item| {
item.unwrap().split_whitespace().position(|item| item == "1")
.and_then(|item| Some(item as i32))
})
.collect();
let vertical_ops = (2 - (matrix.iter().position(|item| *item != None).unwrap() as i32)).abs();
let horizontal_ops = (2 - matrix.iter().find(|item| **item != None).unwrap().unwrap()).abs();
println!("{}", vertical_ops + horizontal_ops);
}

11
339A.rs Normal file
View File

@ -0,0 +1,11 @@
use std::io;
fn main() {
let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
let mut numbers: Vec<String> = buf.trim_end().split('+').map(|item| item.to_string()).collect();
numbers.sort();
println!("{}", numbers.join("+"));
}

18
4A.rs Normal file
View File

@ -0,0 +1,18 @@
use std::io::{self, Read, Write};
fn main() {
let mut stdin = io::stdin();
let mut stdout = io::stdout();
let mut weight_string = String::new();
stdin.read_to_string(&mut weight_string).unwrap();
let weight = weight_string.trim_end().parse::<i32>().unwrap();
if weight % 2 == 0 && weight != 2 {
stdout.write_all(b"YES\n").unwrap();
}
else {
stdout.write_all(b"NO\n").unwrap();
}
}

26
50A.rs Normal file
View File

@ -0,0 +1,26 @@
use std::io::{self, Read, Write};
fn main() {
let mut stdin = io::stdin();
let mut stdout = io::stdout();
let mut input = String::new();
stdin.read_to_string(&mut input).unwrap();
let mut inputs = input.split_whitespace();
let input1 = inputs.next().unwrap();
let input2 = inputs.next().unwrap();
let width = input1.parse::<i32>().unwrap();
let height: i32 = input2.parse().unwrap();
let result =
if width % 2 == 0 || height % 2 == 0 {
width * height / 2
}
else {
(width * height - 1) / 2
};
stdout.write_all(format!("{}\n", result).as_ref()).unwrap();
}