提出 #5798480
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
vector<string> split(const string &s, char c) {
vector<string> v; stringstream ss(s); string x;
while (getline(ss, x, c)) v.push_back(x);
return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
err(++it, args...);
}
typedef long long ll;
const int MOD = 1000003;
template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }
ll ft[1000005];
ll mod_pow(ll x, ll y, ll p) {
ll res = 1;
while (y > 0) {
if (y & 1) res = res * x % p;
x = x * x % p;
y >>= 1;
}
return res;
}
int main(int argc, char *argv[]) {
ios_base::sync_with_stdio(false);
ft[0] = 1;
REPU(i, 1, MOD) ft[i] = i * ft[i - 1] % MOD;
int Q; cin >> Q;
REPU(_, 0, Q) {
ll x, d, n; cin >> x >> d >> n;
if (x == 0) puts("0");
else if (d == 0) {
printf("%lld\n", mod_pow(x, n, MOD));
}
else {
ll invd = mod_pow(d, MOD - 2, MOD);
x = x * invd % MOD;
if (x + n - 1 >= MOD) puts("0");
else {
ll ans = mod_pow(d, n, MOD);
ans = ans * ft[x + n - 1] % MOD * mod_pow(ft[x - 1], MOD - 2, MOD) % MOD;
printf("%lld\n", ans);
}
}
}
return 0;
}
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
600 / 600 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
example0.txt |
| All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, example0.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 000.txt |
AC |
62 ms |
8576 KiB |
| 001.txt |
AC |
62 ms |
8576 KiB |
| 002.txt |
AC |
61 ms |
8576 KiB |
| 003.txt |
AC |
60 ms |
8576 KiB |
| 004.txt |
AC |
60 ms |
8448 KiB |
| 005.txt |
AC |
60 ms |
8448 KiB |
| 006.txt |
AC |
61 ms |
8576 KiB |
| 007.txt |
AC |
60 ms |
8448 KiB |
| 008.txt |
AC |
61 ms |
8448 KiB |
| 009.txt |
AC |
60 ms |
8576 KiB |
| 010.txt |
AC |
60 ms |
8448 KiB |
| 011.txt |
AC |
60 ms |
8448 KiB |
| 012.txt |
AC |
60 ms |
8448 KiB |
| 013.txt |
AC |
57 ms |
8704 KiB |
| 014.txt |
AC |
58 ms |
8704 KiB |
| 015.txt |
AC |
58 ms |
8704 KiB |
| 016.txt |
AC |
57 ms |
8704 KiB |
| 017.txt |
AC |
58 ms |
8704 KiB |
| 018.txt |
AC |
47 ms |
8320 KiB |
| 019.txt |
AC |
47 ms |
8320 KiB |
| example0.txt |
AC |
8 ms |
8064 KiB |