QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#102623#5661. Multi-LaddersWPS#WA 3ms3500kbC++171.5kb2023-05-03 15:13:582023-05-03 15:14:12

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 15:14:12]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3500kb
  • [2023-05-03 15:13:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long

const int mod = 1e9+7;


int power( int x , int y ){
//	cout << x << "^" << y << "=";
	x %= mod;
	if( x < 0 ) x += mod;
	int ans = 1ll;
	while( y ){
		if( y & 1ll ) ans = ans * x % mod;
		x = x * x % mod , y >>= 1ll;
	}
//	cout << ans << "\n";
	return ans;
}

int inv( int x ){
	return power(x , mod - 2ll );
}

int sum( int a , int q , int n ){
//	cout << a << " " << q << " " << n << "\n";
	return a * ( power( q , n ) - 1 ) % mod * inv( q - 1 ) % mod;
}


int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(nullptr) , cout.tie(nullptr);
	int T , n , k , x ;
	cin >> T;
	for( ; T ; T -- ){
		cin >> n >> k >> x;
		if( x < 2 ){
			cout << "0\n";
			continue;
		}
		int ans = 1;
//		cout << x << "\n";
//		ans = ans * sum( x*(x-1)*power( x-2 , k-2 ) % mod , (x-1) * inv( (x-2)*(x-2) ) % mod , k / 2  ) % mod;
//		cout << sum( x*(x-1)*power( x-2 , k-2 ) % mod , (x-1) * inv( (x-2)*(x-2) ) % mod , k / 2  ) % mod << "\n";
//		cout << power( x * x - 3 * x + 3 , (n-1) * k ) % mod << "\n";
	
		//ans = power(x-1,k);
//		if( k & 1 ) ans = ( (ans + x - 1) % mod + mod ) % mod;
//		else ans = ( ( ans + 1 - x ) % mod + mod ) % mod;
		
		
//		cout << x * power( x - 1 , k-2 ) % mod << "\n";
//		cout << power( x * x - 3 * x + 3 , (n-1) * k ) << "\n";
		ans = x * power( x - 1 , k-2 ) % mod;
		ans = ans * power( x * x - 3 * x + 3 , (n-1) * k ) % mod;
		cout << ans << "\n";
	}
	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3336kb

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
2
2
0
276470632
285647315
52489881
186358669
304930780
187785751
422872637
787551670
258401658
851695173
122393842
0
0
798130793

result:

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