結果
問題 | No.3002 多項式の割り算 〜easy〜 |
ユーザー |
|
提出日時 | 2025-02-05 02:13:46 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,390 bytes |
コンパイル時間 | 18,629 ms |
コンパイル使用メモリ | 381,240 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-02-05 02:15:41 |
合計ジャッジ時間 | 14,714 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
コンパイルメッセージ
warning: unused variable: `i` --> src/main.rs:57:9 | 57 | for i in 0..b { | ^ help: if this is intentional, prefix it with an underscore: `_i` | = note: `#[warn(unused_variables)]` on by default warning: methods `string`, `u64`, and `chars` are never used --> src/main.rs:29:8 | 8 | impl Scanner { | ------------ methods in this implementation ... 29 | fn string(&mut self) -> String { | ^^^^^^ ... 37 | fn u64(&mut self) -> u64 { | ^^^ ... 45 | fn chars(&mut self) -> Vec<char> { | ^^^^^ | = note: `#[warn(dead_code)]` on by default
ソースコード
use std::{collections::VecDeque, io::Stdin, str::FromStr};struct Scanner {stdin: Stdin,buf: VecDeque<String>,}impl Scanner {fn new() -> Scanner {Scanner {stdin: std::io::stdin(),buf: VecDeque::new(),}}fn read(&mut self) -> String {loop {if let Some(x) = self.buf.pop_front() {break x;}let mut s = String::new();self.stdin.read_line(&mut s).unwrap();s.trim().split_whitespace().for_each(|x| self.buf.push_back(x.to_string()));}}fn string(&mut self) -> String {self.read()}fn parse<T: FromStr>(&mut self) -> T {self.read().parse().ok().unwrap()}fn u64(&mut self) -> u64 {self.parse()}fn i64(&mut self) -> i64 {self.parse()}fn chars(&mut self) -> Vec<char> {self.string().chars().collect()}}fn main() {let mut scanner = Scanner::new();let a = scanner.i64();let b = scanner.i64();let mut state = [0; 3];state[2] = a;for i in 0..b {state[0] = state[1];state[1] = state[2];state[2] = 0;state[2] -= state[0];state[1] -= state[0];state[0] = 0;}println!("{} {}", state[1], state[2]);}