QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#104092 | #5661. Multi-Ladders | tarjen | AC ✓ | 1ms | 3736kb | C++17 | 751b | 2023-05-08 16:27:07 | 2023-05-08 16:27:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int T;
#define ll long long
const ll mod = 1e9+7;
ll ksm(ll x,ll y)
{
x%=mod;
y%=mod-1;
ll sum = 1;
while (y)
{
if (y&1) sum = sum * x % mod;
x=x*x%mod;
y>>=1;
}
return sum;
}
void work()
{
ll n,k,l;
scanf("%lld%lld%lld",&n,&k,&l);
ll sum1=ksm((l-2)*(l-2)+l-1,n-1);
ll sum2=ksm(sum1,k);
ll sum3=0;
if (k&1) sum3=(1-l)*(1-ksm(1-l,k-1))%mod;
else sum3=(l-1)*(1-ksm(1-l,k-1))%mod;
//cout << sum3<<" \n";
sum3%=mod;
sum3=sum3*sum2%mod;
sum3=(sum3+mod)%mod;
printf("%lld\n", sum3);
}
int main()
{
cin >> T;
while (T--)
{
work();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3696kb
input:
1 2 3 3
output:
162
result:
ok single line: '162'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3736kb
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