結果
| 問題 |
No.721 Die tertia (ディエ・テルツィア)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-24 08:35:10 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,431 bytes |
| コンパイル時間 | 14,097 ms |
| コンパイル使用メモリ | 387,548 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-03 05:26:51 |
| 合計ジャッジ時間 | 14,423 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 18 |
ソースコード
struct Date {
year: u16,
month: u8,
day: u8,
}
impl Date {
#[allow(dead_code)]
fn is_leap_year(&self) -> bool {
let y = self.year;
y % 4 == 0 && (y % 100 > 0 || y % 400 == 0)
}
#[allow(dead_code)]
fn get_month_lastday(&self) -> u8 {
match self.month {
4|6|9|11 => 30,
2 => match self.is_leap_year() {
true => 29,
_ => 28,
},
_ => 31,
}
}
#[allow(dead_code)]
fn increase_year(&mut self) {
self.year = self.year + 1;
}
#[allow(dead_code)]
fn increase_month(&mut self) {
self.month = match self.month {
12 => {
self.increase_year();
1
},
_ => self.month + 1,
};
}
#[allow(dead_code)]
fn increase_day(&mut self) {
if self.day == self.get_month_lastday() {
self.increase_month();
self.day = 1;
} else {
self.day += 1;
}
}
#[allow(dead_code)]
fn show(&self) {
println!("{0:>04}-{1:>02}-{2:>02}", self.year, self.month, self.day);
}
}
use std::io;
fn main(){
let mut input = String::new();
io::stdin().read_line(&mut input).ok();
let mut v = input.trim().split("/");
let y: u16 = v.next().unwrap().parse().unwrap();
let m: u8 = v.next().unwrap().parse().unwrap();
let d: u8 = v.next().unwrap().parse().unwrap();
let mut d = Date {year:y, month:m, day:d};
d.increase_day();
d.increase_day();
d.show();
}