結果
| 問題 |
No.2706 One Nafmo
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-02 23:34:36 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 4,180 bytes |
| コンパイル時間 | 13,570 ms |
| コンパイル使用メモリ | 400,940 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-09-30 23:24:41 |
| 合計ジャッジ時間 | 14,624 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 |
ソースコード
#[allow(unused_imports)]
use crate::lib::*;
use stdin::Scanner;
use stdout::fastout;
fn main() {
// input
let mut sc = Scanner::new(std::io::stdin().lock());
let a: u32 = sc.next();
let b: u32 = sc.next();
let x: u32 = sc.next();
// solve
let ans = solve(a, b, x);
// output
fastout(&ans.to_string());
}
fn solve(a: u32, b: u32, x: u32) -> u32 {
(x + a - 1) / a * b
}
mod lib {
#![allow(dead_code)]
pub mod stdin {
pub struct Scanner<R: std::io::BufRead> {
reader: R,
buf: Vec<u8>,
pos: usize,
}
impl<R: std::io::BufRead> Scanner<R> {
pub fn new(reader: R) -> Self {
Scanner {
reader,
buf: Vec::new(),
pos: 0,
}
}
pub fn with_capacity(reader: R, capacity: usize) -> Self {
Scanner {
reader,
buf: Vec::with_capacity(capacity),
pos: 0,
}
}
pub fn next<T: std::str::FromStr>(&mut self) -> T
where
T::Err: std::fmt::Debug,
{
if self.buf.is_empty() {
self.read_next_line();
}
let mut start = None;
loop {
if self.pos == self.buf.len() {
break;
}
match (self.buf[self.pos], start.is_some()) {
(b' ', true) | (b'\n', true) => break,
(_, true) | (b' ', false) => self.pos += 1,
(b'\n', false) => self.read_next_line(),
(_, false) => start = Some(self.pos),
}
}
let elem =
unsafe { std::str::from_utf8_unchecked(&self.buf[start.unwrap()..self.pos]) };
elem.parse()
.unwrap_or_else(|_| panic!("{}", format!("failed parsing: {}", elem)))
}
fn read_next_line(&mut self) {
self.pos = 0;
self.buf.clear();
if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
panic!("Reached EOF");
}
}
}
}
pub mod stdout {
pub fn fastout(s: &str) {
use std::io::{stdout, BufWriter, Write};
let mut out = BufWriter::new(stdout().lock());
writeln!(out, "{}", s).expect("failed to write data.");
}
}
pub mod num {
pub trait Zero {
fn zero() -> Self;
}
impl Zero for u32 {
fn zero() -> Self {
0
}
}
impl Zero for u64 {
fn zero() -> Self {
0
}
}
impl Zero for usize {
fn zero() -> Self {
0
}
}
}
pub mod math {
use super::num::Zero;
pub fn gcd<T>(a: T, b: T) -> T
where
T: std::marker::Copy,
T: std::cmp::Eq,
T: std::ops::Rem<Output = T>,
T: Zero,
{
if b == T::zero() {
a
} else {
gcd::<T>(b, a % b)
}
}
pub fn lcm<T>(a: T, b: T) -> T
where
T: std::marker::Copy,
T: std::ops::Mul<Output = T>,
T: std::ops::Div<Output = T>,
T: std::ops::Rem<Output = T>,
T: std::cmp::Eq,
T: Zero,
{
a / gcd::<T>(a, b) * b
}
pub fn sieve_of_eratosthenes(end: usize) -> Vec<bool> {
let mut is_prime = vec![true; end + 1];
(is_prime[0], is_prime[1]) = (false, false);
for i in 2..=((end as f64).sqrt() as usize) {
if is_prime[i] {
for j in (i * 2..=end).step_by(i) {
is_prime[j] = false;
}
}
}
is_prime
}
}
}