結果
| 問題 |
No.2784 繰り上がりなし十進和
|
| コンテスト | |
| ユーザー |
naut3
|
| 提出日時 | 2024-06-14 22:52:04 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 544 ms / 2,000 ms |
| コード長 | 1,959 bytes |
| コンパイル時間 | 12,440 ms |
| コンパイル使用メモリ | 378,144 KB |
| 実行使用メモリ | 30,732 KB |
| 最終ジャッジ日時 | 2024-06-14 22:52:33 |
| 合計ジャッジ時間 | 21,402 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
ソースコード
#![allow(non_snake_case, unused_imports)]
use proconio::{fastout, input, marker::*};
#[fastout]
fn main() {
input! {
A: [Chars; 6],
}
let mut S = std::collections::HashSet::new();
let A = [
SixDigitsArray::from(&A[0]),
SixDigitsArray::from(&A[1]),
SixDigitsArray::from(&A[2]),
SixDigitsArray::from(&A[3]),
SixDigitsArray::from(&A[4]),
SixDigitsArray::from(&A[5]),
];
for i0 in 1..=10 {
let s0 = A[0] * i0;
for i1 in 1..=10 {
let s1 = A[1] * i1;
for i2 in 1..=10 {
let s2 = A[2] * i2;
for i3 in 1..=10 {
let s3 = A[3] * i3;
for i4 in 1..=10 {
let s4 = A[4] * i4;
for i5 in 1..=10 {
let s5 = A[5] * i5;
S.insert(s0 + s1 + s2 + s3 + s4 + s5);
}
}
}
}
}
}
for &s in S.clone().iter() {
for i in 1..=5 {
S.insert(s * i);
}
}
println!("{}", S.len());
}
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
struct SixDigitsArray {
a: [u8; 6],
}
impl SixDigitsArray {
fn from(chars: &[char]) -> Self {
let mut a = [0; 6];
for i in 0..6 {
a[i] = chars[i] as u8 - '0' as u8;
}
Self { a }
}
}
impl std::ops::Add for SixDigitsArray {
type Output = Self;
fn add(self, rhs: Self) -> Self::Output {
let mut a = [0; 6];
for i in 0..6 {
a[i] = (self.a[i] + rhs.a[i]) % 10;
}
Self { a }
}
}
impl std::ops::Mul<u8> for SixDigitsArray {
type Output = Self;
fn mul(self, rhs: u8) -> Self::Output {
let mut a = [0; 6];
for i in 0..6 {
a[i] = (self.a[i] * rhs) % 10;
}
Self { a }
}
}
naut3