結果
| 問題 |
No.2709 1975 Powers
|
| コンテスト | |
| ユーザー |
well-defined
|
| 提出日時 | 2024-09-16 17:01:47 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 415 ms / 2,000 ms |
| コード長 | 1,296 bytes |
| コンパイル時間 | 14,770 ms |
| コンパイル使用メモリ | 392,448 KB |
| 実行使用メモリ | 64,512 KB |
| 最終ジャッジ日時 | 2024-09-16 17:02:09 |
| 合計ジャッジ時間 | 20,683 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
use proconio::input;
fn main () {
input! {
n: usize,
p: usize,
q: usize,
mut arr: [usize; n],
}
arr.sort();
let apow: Vec<usize> = std::iter::successors(Some(10), |&prev| Some((prev * 10) % p))
.take(arr[n-1] as usize)
.collect();
let bpow: Vec<usize> = std::iter::successors(Some(9), |&prev| Some((prev * 9) % p))
.take(arr[n-1] as usize)
.collect();
let cpow: Vec<usize> = std::iter::successors(Some(7), |&prev| Some((prev * 7) % p))
.take(arr[n-1] as usize)
.collect();
let dpow: Vec<usize> = std::iter::successors(Some(5), |&prev| Some((prev * 5) % p))
.take(arr[n-1] as usize)
.collect();
let mut ans: usize = 0;
for i in 0..n {
let a = arr[i];
for j in i+1..n {
let b = arr[j];
for k in j+1..n {
let c = arr[k];
for l in k+1..n {
let d = arr[l];
//println!("a: {}, b: {}, c: {}, d: {}",a,b,c,d);
let val = (apow[a-1] + bpow[b-1] + cpow[c-1] + dpow[d-1]) % p;
if val == q {
ans += 1;
}
}
}
}
}
println!("{}", ans);
}
well-defined