QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102559#5661. Multi-LaddersJoler#WA 2ms3388kbC++142.0kb2023-05-03 14:38:592023-05-03 14:39:01

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 14:39:01]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3388kb
  • [2023-05-03 14:38:59]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#ifdef LOCAL
template<class t,class u>ostream& operator<<(ostream& os,const pair<t,u>& p){return os<<"("<<p.first<<","<<p.second<<")";}
#endif
template<class t>ostream& operator<<(ostream& os,const vector<t>& v){if(v.size())os<<v[0];for(int i=1; i<v.size(); i++)os<<' '<<v[i]; return os;}
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
ll n, m, t, k, a, b, c, d, cnt, mark, an, oT_To, x, y, z;
ll ans;
#define int ll
const int mod = 1e9+7;

array<array<int, 2>, 2> A = {array<int, 2>{0, 1}};
struct jz {
    array<array<int, 2>, 2> a{};
};
jz operator*(const jz& ja, const jz& jb) {
    array<array<int, 2>, 2> res{};
    for (int i : {0, 1}) for (int j : {0, 1}) for (int l : {0, 1})
        (res[i][j] += ja.a[i][l] * jb.a[l][j] % mod) %= mod;
    return {res};
}

jz ksm (jz a, int b) {
    jz res{array<int, 2>{1, 0}, array<int, 2>{0, 1}};
    while (b) {
        if (b & 1) res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll ksm(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) (res *= a) %= mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}
struct Solver {
	void solve() {
        cin >> n >> m >> k;
        A[1][0] = k - 1;
        A[1][1] = k - 2;
        if (k <= 1) return cout << "0\n", void();
        if (k == 2) {
            if (m == 3) cout << "0\n";
            else cout << 2 << '\n';
            return;
        }
        
        auto p = ksm({A}, m-1);
        ll y = p.a[1][0];
//        cout << "x: " << x << '\n';
//        cout << "y: " << y << '\n';
        ll ans = (y * k) % mod * ksm(((k-1)*(k-1)-k+2) % mod, (n-1)*m) % mod;
        cout << ans << '\n';
	}
};
#undef int
int main () {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    oT_To = 1;
    cin >> oT_To;
    while (oT_To--) {
    	Solver solver;
        solver.solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3336kb

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3388kb

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
349400141
243010659
52489881
53690844
176686901
218103365
558243892
991895211
693053429
883715672
80402569
0
0
311752813

result:

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