結果

問題 No.2568 列辞書順列列
ユーザー tenbatenba
提出日時 2023-12-02 16:59:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,304 bytes
コンパイル時間 952 ms
コンパイル使用メモリ 103,968 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 16:59:52
合計ジャッジ時間 6,398 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define SZ(x) ((int)(x).size());
#define vec vector
template <class T>
using v = vector<T>;
template <class T>
using vv = v< v<T> >;
template <class T>
using vvv = v< vv<T> >;
#define el '\n'
#define vl v<ll>
#define vvl vv<ll>
#define pl pair<ll, ll>
#define repab(i, a, b) for(ll i = a; a < (ll)(b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define rep1(i, n) for(ll i = 1; i <= (ll)(n); ++i)
#define rrep(i, n) for(ll i = ((ll)(n) - 1); i >= 0; --i)
#define rrep1(i, n) for(ll i = ((ll)(n)); i > 0; --i)
#define YN(x) cout << ((x) ? "YES\n" : "NO\n");
#define Yn(x) cout << ((x) ? "Yes\n" : "No\n");
#define yn(x) cout << ((x) ? "yes\n" : "no\n");
#define COUT(x) cout << (x) << el;
const double pi = 3.141592653589793238;
const int inf = 1073741823;
const ll infl = 1LL << 60;

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    int n,m,q;
    cin >> n >> m >> q;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll mod = 998244353;
    rep(i,q){
        ll l,r;
        cin >> l >> r;
        l--; r--;
        ll ans = 0;
        ll leng = r - l + 1;
        ll tmp = 1;
        for(int j = r; j >= l; --j){
            ans += (((a[j] - 1) % mod) * (tmp % mod)) % mod;
            tmp *= (m % mod);
        }
        cout << ans << endl;
    }

    return 0;
}
0