結果
| 問題 | 
                            No.16 累乗の加算
                             | 
                    
| コンテスト | |
| ユーザー | 
                             hitoyozake
                         | 
                    
| 提出日時 | 2018-07-25 23:42:29 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 922 bytes | 
| コンパイル時間 | 21,610 ms | 
| コンパイル使用メモリ | 401,004 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-27 07:20:26 | 
| 合計ジャッジ時間 | 13,342 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 14 | 
コンパイルメッセージ
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;
        sum = sum % 1000003;
    }
    println!("{}", sum);
}
            
            
            
        
            
hitoyozake