結果
| 問題 |
No.915 Plus Or Multiple Operation
|
| コンテスト | |
| ユーザー |
fukafukatani
|
| 提出日時 | 2019-10-25 22:37:07 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,403 bytes |
| コンパイル時間 | 20,471 ms |
| コンパイル使用メモリ | 397,240 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-07 03:35:17 |
| 合計ジャッジ時間 | 21,340 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 1 WA * 9 |
コンパイルメッセージ
warning: unused variable: `i`
--> src/main.rs:20:9
|
20 | for i in 0..q {
| ^ help: if this is intentional, prefix it with an underscore: `_i`
|
= note: `#[warn(unused_variables)]` on by default
ソースコード
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
#[allow(unused_macros)]
macro_rules! debug {
($($e:expr),*) => {
#[cfg(debug_assertions)]
$({
let (e, mut err) = (stringify!($e), std::io::stderr());
writeln!(err, "{} = {:?}", e, $e).unwrap()
})*
};
}
fn main() {
let q = read::<usize>();
for i in 0..q {
let v = read_vec::<i64>();
let (a, b, c) = (v[0], v[1], v[2]);
if c == 1 {
println!("{}", a * b);
continue;
}
let mut ans = 0;
let mut cur_multiplied = 1;
let mut loop_cnt = 0;
while cur_multiplied * c < a {
cur_multiplied *= c;
loop_cnt += 1;
}
ans += loop_cnt;
let mut a = a;
while a != 0 {
a -= a / cur_multiplied * cur_multiplied;
ans += 1;
while cur_multiplied > a {
cur_multiplied /= c;
}
}
println!("{}", ans * b);
}
}
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>()
.split_whitespace()
.map(|e| e.parse().ok().unwrap())
.collect()
}
fukafukatani