QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#85933 | #5661. Multi-Ladders | yyyyxh | AC ✓ | 1ms | 1748kb | C++14 | 741b | 2023-03-08 21:20:04 | 2023-03-08 21:20:06 |
Judging History
answer
#include <cstdio>
using namespace std;
int read(){
char c=getchar();int x=0;
while(c<48||c>57) c=getchar();
do x=(x<<1)+(x<<3)+(c^48),c=getchar();
while(c>=48&&c<=57);
return x;
}
const int P=1000000007;
typedef long long ll;
int n,k,s;
int qp(int a,int b=P-2){
int res=1;
while(b){
if(b&1) res=(ll)res*a%P;
a=(ll)a*a%P;b>>=1;
}
return res;
}
int main(){
int tc=read();
while(tc--){
n=read();k=read();s=read();
if(s<=1){
puts("0");
continue;
}
int res=qp(s-1,k);
if(k&1) res=(res+P-s+1)%P;
else res=(res+P+s-1)%P;
if(res){
int coe=((ll)(s-2)*(s-2)+(s-1))%P;
res=(ll)res*qp(coe,(ll)(n-1)*k%(P-1))%P;
printf("%d\n",res);
}
else puts("0");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 1496kb
input:
1 2 3 3
output:
162
result:
ok single line: '162'
Test #2:
score: 0
Accepted
time: 1ms
memory: 1748kb
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