Submission #20843039


Source Code Expand

#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = 3.14159265359;
const ll INF = 1LL << 60;

long long modpow(long long x, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
  ll n, m, k;
  cin >> n >> m >> k;

  ll ans = 0;
  const ll p = 998244353;
  
  if (n == 1){
    ans = modpow(k, m, p) % p;
  } else if (m == 1){
    ans = modpow(k, n, p) % p;
  } else {
    for (int i = 1; i <= k; i++){
      ans += (modpow(i, n, p) - modpow((i-1), n, p) + p) % p * modpow(k-i+1, m, p) % p;
      ans %= p;
    }
  }

  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task D - Sky Reflector
User unnohideyuki
Language C++ (GCC 9.2.1)
Score 600
Code Size 815 Byte
Status AC
Exec Time 45 ms
Memory 3620 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 15
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 45 ms 3460 KiB
02.txt AC 22 ms 3400 KiB
03.txt AC 2 ms 3408 KiB
04.txt AC 2 ms 3524 KiB
05.txt AC 2 ms 3404 KiB
06.txt AC 2 ms 3392 KiB
07.txt AC 2 ms 3456 KiB
08.txt AC 3 ms 3568 KiB
09.txt AC 11 ms 3516 KiB
10.txt AC 17 ms 3616 KiB
11.txt AC 5 ms 3400 KiB
12.txt AC 2 ms 3580 KiB
s1.txt AC 2 ms 3620 KiB
s2.txt AC 2 ms 3576 KiB
s3.txt AC 18 ms 3592 KiB