結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
hitoyozake
|
| 提出日時 | 2018-07-25 23:39:30 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 893 bytes |
| コンパイル時間 | 13,845 ms |
| コンパイル使用メモリ | 380,008 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-27 07:17:39 |
| 合計ジャッジ時間 | 14,594 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 10 |
コンパイルメッセージ
warning: unused variable: `r` --> src/main.rs:5:9 | 5 | let r = std::io::stdin().read_line(& mut x); | ^ help: if this is intentional, prefix it with an underscore: `_r` | = note: `#[warn(unused_variables)]` on by default
ソースコード
fn read_line()->String{
let mut x = String::new();
let r = std::io::stdin().read_line(& mut x);
x
}
fn bin_pow(x:u64, mut n:u64)->u64{
let mut y:u64 = 1;
let mut p:u64 = x;
while n > 0{
if n % 2 == 0 {
p = (p % 1000003) * (p % 1000003);
n /= 2;
}
else{
y = (y%1000003) * (p % 1000003);
n -= 1;
}
}
y
}
fn main() {
let a = read_line();
let a_array:Vec<&str> = a.split(' ').collect();
let base = a_array[0].parse::<u64>().unwrap();
let b = read_line();
let trimed_b = b.trim();
let numbers_s: Vec<&str> = trimed_b.split(' ').collect();
let mut sum:u64 = 0;
for num_s in numbers_s{
let num= num_s.parse::<u64>().unwrap();
//println!("{}", base);
sum += bin_pow(base, num)%1000003;
}
println!("{}", sum);
}
hitoyozake