QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#85108#5661. Multi-LadderspiasticOuO#WA 1ms3424kbC++142.0kb2023-03-06 23:18:452023-03-06 23:18:47

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-06 23:18:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3424kb
  • [2023-03-06 23:18:45]
  • 提交

answer

#include <iostream>
using namespace std;
const long long modf = 1e9 + 7;
long long T, n, k, u;
long long fjz[3][3], xl[3];

long long qc(long long x, long long y) {
	long long uu = 1;
	while (y) {
		if (y & 1)
			uu = uu * x % modf;
		x = x * x % modf;
		y >>= 1;
	}
	return uu;
}

void jzqc(long long y) {
	long long tmpjz[3][3], njz[3][3];
	tmpjz[1][1] = u - 2, tmpjz[2][1] = u - 1;
	tmpjz[1][2] = 1, tmpjz[2][2] = 0;
	fjz[1][1] = 1;
	fjz[2][2] = 1;
	while (y) {
		if (y & 1) {
			for (int i = 1; i <= 2; ++i) {
				for (int j = 1; j <= 2; ++j) {
					njz[i][j] = fjz[i][j];
				}
			}
			fjz[1][1] = njz[1][1] * tmpjz[1][1] + njz[1][2] * tmpjz[2][1];
			fjz[1][2] = njz[1][1] * tmpjz[1][2] + njz[1][2] * tmpjz[2][2];
			fjz[2][1] = njz[2][1] * tmpjz[1][1] + njz[2][2] * tmpjz[2][1];
			fjz[2][2] = njz[2][1] * tmpjz[1][2] + njz[2][2] * tmpjz[2][2];
			for (int i = 1; i <= 2; ++i) {
				for (int j = 1; j <= 2; ++j) {
					fjz[i][j] %= modf;
				}
			}
		}
		for (int i = 1; i <= 2; ++i) {
			for (int j = 1; j <= 2; ++j) {
				njz[i][j] = tmpjz[i][j];
			}
		}
		tmpjz[1][1] = njz[1][1] * njz[1][1] + njz[1][2] * njz[2][1];
		tmpjz[1][2] = njz[1][1] * njz[1][2] + njz[1][2] * njz[2][2];
		tmpjz[2][1] = njz[2][1] * njz[1][1] + njz[2][2] * njz[2][1];
		tmpjz[2][2] = njz[2][1] * njz[1][2] + njz[2][2] * njz[2][2];
		for (int i = 1; i <= 2; ++i) {
			for (int j = 1; j <= 2; ++j) {
				tmpjz[i][j] %= modf;
			}
		}
		y >>= 1;
	}
}

void solve() {
	cin >> n >> k >> u;
	if (u <= 2) {
		cout << 0;
		return;
	}
	//\xd6\xdcΧ
	long long d = ((u - 2) * (u - 2) % modf + u - 1) % modf;
	long long v = k * (n - 1) % modf;
	long long dy = qc(d, v);
	//\xbb\xb7
	xl[1] = u * (u - 1) % modf, xl[2] = 0;

	jzqc(k - 1);
	long long c = fjz[1][2] * xl[1] % modf + fjz[2][2] * xl[2] % modf;
	c %= modf;
	long long ans = c * dy % modf;
	cout << ans << '\n';
}

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> T;
	while (T--) {
		solve();
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

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

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
18
0000739396815
589051527
804326833
566950323
808364051
594676829
349198885
850413123
350095803
147495829
214731445
00319423268

result:

wrong answer 2nd lines differ - expected: '6', found: '18'