QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#184632 | #5661. Multi-Ladders | SayedHassan# | WA | 0ms | 3668kb | C++14 | 1.0kb | 2023-09-21 00:17:12 | 2023-09-21 00:17:12 |
Judging History
answer
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll power(ll a,ll p)
{
ll ret=1;
while(p)
{
if(p&1)ret=(ret*a)%MOD;
a=(a*a)%MOD;
p/=2;
}
return ret;
}
int main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
cin>>t;
while(t--)
{
ll n,k,c;
cin>>n>>k>>c;
if(c<2)
{
cout<<0<<'\n';
continue;
}
if(c==2&&k%2)
{
cout<<0<<'\n';
continue;
}
ll tmp=power((c-2)*(c-3)+(c-2)*2+1,n-1);
tmp=power(tmp,k);
tmp*=power(2,MOD-2);
tmp%=MOD;
ll rep=c*power(c-1,k-1);
rep%=MOD;
if(k%2)
{
rep-=(power(c-2,k-1)-1);
}
else
{
rep-=(power(c-2,k-1)+1);
}
rep+=MOD;
rep%=MOD;
cout<<(tmp*rep)%MOD<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
input:
1 2 3 3
output:
162
result:
ok single line: '162'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3616kb
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 763806629 860970611 52489881 950419031 934920361 69289293 777836755 408063774 795846694 493252920 903075007 0 0 800080441
result:
wrong answer 7th lines differ - expected: '349400141', found: '763806629'