QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#133211#5661. Multi-Ladderstselmegkh#AC ✓1ms3480kbC++201.3kb2023-08-01 18:42:412023-08-01 18:42:43

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-01 18:42:43]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3480kb
  • [2023-08-01 18:42:41]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;

const int N = 2e5 + 5, inf = 1e9;
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define sz(x) (int)x.size()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const ll mod = 1e9 + 7;

ll binpow(ll a, ll b){
    ll res = 1;
    a %= mod;
    while(b > 0){
        if(b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

ll add(ll a, ll b){
    a += b;
    a %= mod;
    return a;
}

ll mul(ll a, ll b){
    a %= mod;
    a *= b;
    a %= mod;
    return a;
}

void solve(){
    ll n, k, y;
    cin >> n >> k >> y;

    ll res = mul(add(binpow(y - 1, k), mul(binpow(-1, k), (y - 1))), binpow(binpow(y * y - 3 * y + 3, n - 1), k));
    while(res < 0){
        res += mod;
    }
    cout << res << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3480kb

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3480kb

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