結果
| 問題 |
No.1281 Cigarette Distribution
|
| コンテスト | |
| ユーザー |
fukafukatani
|
| 提出日時 | 2020-11-06 23:10:30 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,605 bytes |
| コンパイル時間 | 16,494 ms |
| コンパイル使用メモリ | 403,784 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-22 13:35:06 |
| 合計ジャッジ時間 | 14,932 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 12 |
コンパイルメッセージ
warning: unused variable: `i`
--> src/main.rs:26:9
|
26 | for i in 1..11 {
| ^ help: if this is intentional, prefix it with an underscore: `_i`
|
= note: `#[warn(unused_variables)]` on by default
ソースコード
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;
#[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 v = read_vec::<i64>();
let (n, m) = (v[0], v[1]);
println!("{}", n);
for x in 2..m + 1 {
println!("{}", solve(x, n));
}
for i in 1..11 {
debug!(solve(4, i));
}
}
fn solve(x: i64, n: i64) -> i64 {
let mut n = n;
if n <= x {
return 0;
}
n -= x;
let min_n = n / x;
let mid_n = min_n + 1;
let max_n = min_n + 2;
let res = n % x;
// debug!(n, res);
if res == x - 1 {
// debug!(mid_n, max_n, res);
mid_n * pow(max_n, res)
} else {
// debug!(mid_n, max_n, res);
min_n * pow(max_n, res + 1) * pow(mid_n, x - (res + 2))
}
}
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()
}
fn pow(n: i64, mut p: i64) -> i64 {
let mut r = n;
let mut ret = 1;
while p > 0 {
if p % 2 == 0 {
r = r * r;
p /= 2;
} else {
ret = ret * r;
p -= 1;
}
}
ret
}
fukafukatani