QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#323075#5661. Multi-LaddersRabeya#AC ✓0ms3720kbC++231.4kb2024-02-08 12:48:362024-02-08 12:48:37

Judging History

你现在查看的是最新测评结果

  • [2024-02-08 12:48:37]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3720kb
  • [2024-02-08 12:48:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef unordered_map<int,int> umap;
typedef long double ld;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define popcount __builtin_popcount
#define case cout<<"Case "<<__testcase-testcase<<":";
#define endl '\n'
const ll mod=1e9+7;
ll power(ll a,ll n=mod-2){
    ll ans=1ll;
    a = (mod+a)%mod;
    n%=(mod-1);
    while(n){
        if(n&1ll) ans=(ans*a)%mod;
        a=(a*a)%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcase=1;
    cin>>testcase;
    int __testcase=testcase;
    while(testcase--)
    {
        ll n,m,i,j,k,l;
        cin>>n>>k>>l;
        if(l<2){
            cout<<0<<endl;
            continue;
        }
        ll ans=power((l-1)+(l-2)*(l-2), n*k-k);
        ll temp;
        ll x=l-1;
        if(k%2==0){
            temp = (power(x,k)-1)*power(x+1) %mod;
            temp = (temp+1)%mod;
            temp = (temp*l)%mod;
        }
        else{
            temp = (power(x,k)+1)*power(x+1) %mod;
            temp = (mod+temp-1)%mod;
            temp = (temp*l)%mod;
        }

        cout<<(ans*temp %mod)<<endl;

    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3656kb

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3720kb

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