QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#306995#8033. Fast ModQingyuAC ✓931ms2228kbRust691b2024-01-17 19:13:362024-01-17 19:13:36

Judging History

你现在查看的是最新测评结果

  • [2024-01-17 19:13:36]
  • 评测
  • 测评结果:AC
  • 用时:931ms
  • 内存:2228kb
  • [2024-01-17 19:13:36]
  • 提交

answer

use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let nums: Vec<u64> = input
        .split_whitespace()
        .map(|num| num.parse().unwrap())
        .collect();

    let (alpha, beta, mut x0, mut y0, mut x1, mut y1, n, m) = (
        nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6], nums[7],
    );

    let mut sum = 0;

    for _ in 2..=n {
        let new_x = (alpha * x1 + x0 * y1) % m;
        let new_y = (beta * y1 + y0 * x1) % m;

        sum = (sum + new_x) % m;

        x0 = x1;
        x1 = new_x;
        y0 = y1;
        y1 = new_y;
    }

    println!("{}", sum);
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 2160kb

input:

114 514 1919 810 2024 112 154 12345678

output:

10095098

result:

ok answer is '10095098'

Test #2:

score: 0
Accepted
time: 93ms
memory: 2228kb

input:

299441828 557975370 185825413 389867512 789055585 702427833 10000000 998244353

output:

213479368

result:

ok answer is '213479368'

Test #3:

score: 0
Accepted
time: 276ms
memory: 2008kb

input:

201640599 316730877 236731096 870547384 321803723 818638005 30000000 998244353

output:

184315876

result:

ok answer is '184315876'

Test #4:

score: 0
Accepted
time: 931ms
memory: 2112kb

input:

454295813 797560957 820671325 549131050 200870107 596997226 100000000 998244353

output:

571671285

result:

ok answer is '571671285'

Test #5:

score: 0
Accepted
time: 931ms
memory: 2080kb

input:

568746783 797268245 962129329 543463404 966124052 703429023 100000000 999999999

output:

890564628

result:

ok answer is '890564628'

Test #6:

score: 0
Accepted
time: 931ms
memory: 2168kb

input:

134942359 726105292 765855056 658375599 203861321 577278130 100000000 1000000000

output:

837667109

result:

ok answer is '837667109'

Test #7:

score: 0
Accepted
time: 931ms
memory: 2112kb

input:

241497218 519623971 533438442 343085870 157943693 105603836 100000000 999999996

output:

122500520

result:

ok answer is '122500520'

Extra Test:

score: 0
Extra Test Passed