QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#725797#5661. Multi-Laddersasd7766zxc#WA 1ms3608kbC++202.7kb2024-11-08 20:04:092024-11-08 20:04:09

Judging History

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

  • [2024-11-08 20:04:09]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3608kb
  • [2024-11-08 20:04:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define masterspark ios::sync_with_stdio(0), cin.tie(0),cout.tie(0),cin.exceptions(cin.failbit);

template<class F, class S> ostream &operator<<(ostream &s, pair<F, S> v) { return s << "(" << v.first << ", " << v.second << ")";} 
template<class F, class S> istream &operator>>(istream &s, pair<F, S> &v) { return s >> v.first >> v.second; }
template<class T> istream &operator>>(istream &s, vector<T> &a) { for (auto &x:a) s>>x; return s; }
template<class T> ostream &operator<<(ostream &s, vector<T> &a) { int n=a.size(); if (!n) return s; s<<a[0]; for (int i=1; i<n; i++) s<<' '<<a[i]; return s; }
 
#define int long long
#define pp pair<int, int>
#define ff first
#define ss second

#define forr(i,n) for(int i = 1; i <= n;++i)
#define rep(i,j,n) for(int i = j; i < n;++i)
#define PB push_back
#define PF push_front
#define EB emplace_back
#define all(v) (v).begin(), (v).end()
#define FZ(x) memset(x, 0, sizeof(x)) //fill zero
#define SZ(x) ((int)x.size())
bool chmin(auto &a, auto b) { return (b < a) and (a = b, true); }
bool chmax(auto &a, auto b) { return (a < b) and (a = b, true); }
using i128 = __int128_t;
using i64 = int64_t;
using i32 = int32_t;

const int mod = 1e9 + 7;
void solve(){
    int n, k, l; cin >> n >> k >> l;
    vector<vector<i64>> ans(2, vector<i64> (2, 0));
    
    ans[0][0] = l-2;
    ans[0][1] = l - 1;
    ans[1][0] = 1;
    ans[1][1] = 0;
    auto mul = [&](vector<vector<i64>> aaa, vector<vector<i64>> bbb) {
        vector<vector<i64>> tmp(2, vector<i64> (2, 0));
        for (i32 i = 0; i < 2; i++) for (i32 l = 0; l < 2; l++) for (i32 k = 0; k < 2; k++) tmp[i][l] += (aaa[i][k] * bbb[k][l]) % mod, tmp[i][l] %= mod;
        return tmp;
    };

    auto ksm = [&](vector<vector<i64>> aaa, int n) {
        vector<vector<i64>> res(2, vector<i64> (2, 0));
        res[0][0] = res[1][1] = 1;
        for (; n; n >>= 1, aaa = mul(aaa, aaa)) if (n & 1) res = mul(res, aaa); 
        return res;
    };
    auto ksm2 = [&](int a, int n) {
        int res = 1;
        for (; n; n >>= 1, a = (a * a) % mod) if (n & 1) res = res * a % mod;
        return res;
    };
    // ans = mul(ans, ans);
    // cout << ans[1][0] << '\n';
    ans = ksm(ans, n);
    int kkkk = (ans[0][1] * l) % mod;

    int tmp = (((l * l) % mod - (3 * l) % mod + 3) + mod) % mod;
    kkkk = (kkkk * ksm2(tmp, (n - 1) * k)) % mod;
    cout << kkkk << '\n';
}
signed main()
{
    masterspark
    int t = 1;
    // freopen("stdin","r",stdin);
    // freopen("stdout","w",stdout);
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
} 

/*
     /\_/\
    (= ._.)
    / >  \>
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3548kb

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
2
0
813875871
45503647
154651759
415637863
176686901
992542368
775737591
619947578
90
830000007
830000007
0
0
884845171

result:

wrong answer 5th lines differ - expected: '0', found: '2'