Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
98072 | ZZQ | 早凉的程序2 | C++ | 解答错误 | 20 | 52 MS | 15864 KB | 1013 | 2023-08-14 11:58:34 |
//20pts #include <bits/stdc++.h> using namespace std; #define int long long inline int Read() { int x = 0 , f = 1; char c = getchar(); for( ; c < '0' || c > '9' ; c = getchar() ) f ^= ( c == '-' ); for( ; c >= '0' && c <= '9' ; c = getchar() ) x = ( x << 3 ) + ( x << 1 ) + ( c ^ 48 ); return f ? x : -x; } const int _ = 1e6 + 5; int n , m , p; int a[_] , d[_]; void Subtask1() { while( m-- ) { int l = Read() , r = Read(); printf( "%lld\n" , ( d[ r ] - d[ l - 1 ] ) % p ); } exit( 0 ); } void Subtask2() { while( m-- ) { int l = Read() , r = Read(); printf( "%lld\n" , d[ r ] - d[ l - 1 ] - p * ( r - l + 1 ) ); } exit( 0 ); } signed main() { n = Read() , m = Read() , p = Read(); int b1 = 1 , b2 = 1; for( int i = 1 ; i <= n ; i++ ) { a[ i ] = Read(); b1 &= ( 0 <= a[ i ] && a[ i ] < p ); b2 &= ( a[ i ] >= p ); d[ i ] = d[ i - 1 ] + a[ i ]; } if( b1 ) Subtask1(); if( b2 ) Subtask2(); return 0; }