QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#147486 | #5661. Multi-Ladders | TJ_Andeviking | AC ✓ | 1ms | 3592kb | C++20 | 1.1kb | 2023-08-23 10:47:58 | 2023-08-25 01:33:09 |
Judging History
answer
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128_t int128;
typedef pair<int, int> pii;
#define iofast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define lowbit(x) (x&(-x))
#define inv(x) qpow(x,mod-2)
#define debug(x) cout << (#x) << " = " << x << endl
#define range(x) (x).begin(), (x).end()
const int iINF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1000000007;
ll qpow(ll a, ll b)
{
ll ans = 1;
a %= mod;
for (; b;b >>= 1) {
if (b & 1)
ans = ans * a % mod;
a = a * a % mod;
}
return ans % mod;
}
/*---------------------------------------*/
void solve()
{
ll n, k, m;
cin >> n >> k >> m;
ll ans = 0;
if (k % 2 == 0)
ans = qpow(m - 1, k) + m - 1;
else
ans = qpow(m - 1, k) - m + 1;
(ans += mod) %= mod;
(ans *= qpow(qpow(m * m - 3 * m + 3, n - 1), k)) %= mod;
cout << ans << '\n';
}
/*---------------------------------------*/
int main()
{
iofast;
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3572kb
input:
1 2 3 3
output:
162
result:
ok single line: '162'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
20 2 3 3 1 3 3 10 3 0 10 3 2 1 21 2 1 22 0 2000 15000 2000 12000 30000 200000 1000000000 3 3 2 1000000000 3 2 3 100000000 1000000000 1000000000 10 1000000000 3 100000000 2 1000000000 100000000 1 1000000000 10 1 1000000000 100000000 1 1000 100000000 1000000000 1000000000 0 1000000000 1000000000 1 100...
output:
162 6 0 0 0 0 349400141 243010659 52489881 53690844 176686901 218103365 558243892 991895211 693053429 883715672 80402569 0 0 311752813
result:
ok 20 lines