QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#110353 | #5661. Multi-Ladders | ycccc319# | WA | 2ms | 3324kb | C++20 | 1.0kb | 2023-06-01 17:15:42 | 2023-06-01 17:15:44 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
const ll mod =(int)1e9+7;
using namespace std;
inline ll qMul(ll a, ll b, ll mod)
{
ll tmp = (a * b - (ll)((long double)a / mod * b + 1.0e-8) * mod);
return tmp < 0 ? tmp + mod : tmp;
}
// 快速幂
ll qPow(ll base, ll power, ll mod)
{
ll ans = 1;
while (power)
{
if (power & 1)
{
ans = qMul(ans, base, mod);
}
base = qMul(base, base, mod);
power >>= 1;
}
return ans % mod;
}
ll g(ll n,ll k,ll x)
{
ll o=(x-2)*(x-2)%mod+2*(x-2)%mod;
o=o%mod;
ll gg= qPow(o,n-1,mod);
ll ggg= qPow(gg,x,mod);
return ggg%mod;
}
ll f(ll n,ll k,ll x)
{
ll ans1=x* qPow(x-1,k-1,mod)%mod;
ll ans2=x* qPow(x-1,k-2,mod)%mod;
ll ans=((ans1-ans2)%mod+mod)%mod;
return ans;
}
int main()
{
int l;
cin>>l;
while (l--)
{
ll n,k,x;
cin>>n>>k>>x;
// cout<<f(n,k,x);
ll ans=g(n,k,x)*f(n,k,x)%mod;
cout<<ans<<"\n";
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3304kb
input:
1 2 3 3
output:
162
result:
ok single line: '162'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3324kb
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 62855849 976722311 52489881 97656251 285575040 234638152 540053077 79598110 67213250 423049 869536635 0 0 399137105
result:
wrong answer 7th lines differ - expected: '349400141', found: '62855849'