結果
| 問題 | No.188 HAPPY DAY |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-16 02:36:39 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 1,306 bytes |
| 記録 | |
| コンパイル時間 | 12,291 ms |
| コンパイル使用メモリ | 387,724 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-16 02:36:53 |
| 合計ジャッジ時間 | 13,218 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 |
ソースコード
#![allow(unused_imports)]
#![allow(non_snake_case)]
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
fn main() {
let months = 12;
let days1 = 9;
let days2 = 3;
let result = solve(months, days2, days1);
println!("{}", result);
}
fn solve(months: usize, tens_digit: usize, ones_digit: usize) -> usize {
let mut count = 0;
for month in 1..=months {
for tens in 0..=tens_digit {
if month == 2 && tens > 2 {
continue;
}
for ones in 0..=ones_digit {
if tens == 0 && ones == 0 {
continue;
}
if !is_valid(month, tens, ones) {
continue;
}
if tens + ones == month {
count += 1;
}
}
}
}
count
}
fn is_valid(month: usize, tens: usize, ones: usize) -> bool {
match tens {
3 => {
if [4, 6, 9, 11].contains(&month) {
return false;
}
if ones > 1 {
return false;
}
}
2 => {
if month == 2 && ones > 8 {
return false;
}
}
_ => {}
}
true
}