Rust,0pts求调
查看原帖
Rust,0pts求调
808714
the_three_body楼主2024/10/1 07:52

代码:

use std::io;
fn main() {
    let mut a:i128;
    let mut b:i128;
    let mut p:i128;
    let mut input = String::new();
    //输入,中间有空格
    io::stdin().read_line(&mut input).expect("Error reading line");
    let mut iter = input.split_whitespace();
    a = iter.next().unwrap().parse::<i128>().unwrap();
    b = iter.next().unwrap().parse::<i128>().unwrap();
    p = iter.next().unwrap().parse::<i128>().unwrap();
    let mut result:i128 = 1;
    let mut base = a % p;
    while b > 0 {
        if b & 1 == 1 {
            result = (result * base) % p;
        }
        base = (base * base) % p;
        b >>= 1;
    }
    println!("{}", result);
}

调了很长时间,样例过了,但是测试点一个都没过

2024/10/1 07:52
加载中...