QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#262443#5661. Multi-LaddershazeAC ✓0ms3752kbC++201.5kb2023-11-23 19:34:012023-11-23 19:34:02

Judging History

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

  • [2023-11-23 19:34:02]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3752kb
  • [2023-11-23 19:34:01]
  • 提交

answer

#include<bits/stdc++.h>
#define irep(i,l,r) for(int (i) = (l); (i) <= (r); ++(i))
#define drep(i,r,l) for(int (i) = (r); (i) >= (l); --(i))
#define ceil(pp,qq) (((pp)>0)^((qq)>0)?-abs(pp)/abs(qq):(pp)%(qq)?(pp)/(qq)+1:(pp)/(qq))
#define floor(pp,qq) (((pp)>0)^((qq)>0)?-ceil(abs(pp),abs(qq)):(pp)/(qq))
#define ll long long
#define LL __int128
using namespace std;

inline ll read(){
	char ch = getchar();
	ll s = 0; bool w = 0;
	while(!isdigit(ch)){if(ch == '-')w = 1;ch = getchar();}
	while(isdigit(ch))s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
	return w ? - s : s;
}

inline char rc(){
	char ch = getchar();
	while(1){
		if(ch >= 'A' && ch <= 'Z')return ch;
		if(ch >= 'a' && ch <= 'z')return ch;
		ch = getchar();
	}
}

template<class T1, class T2>
T1 min(T1 AA, T2 BB){return AA > BB ? BB : AA;}
template<class T1, class T2>
T1 max(T1 AA, T2 BB){return AA < BB ? BB : AA;}

const int itinf = 1e9;
const ll llinf = 4e18;
const int mod = 1000000007;
const int N = 500009;

ll qpow(ll base, ll b){
	ll ans = 1;
	while(b){
		if(b & 1)ans *= base, ans %= mod;
		base *= base, base %= mod, b >>= 1;
	}
	return ans;
}

int main(){
	int DAIDAISHU = read();
	while(DAIDAISHU --){
		ll n = read(), k = read(), lam = read();
		if(lam < 2)puts("0");
		else if(lam == 2){
			if(k & 1)puts("0");
			else puts("2");
		}
		else{
			printf("%lld\n",
			(qpow(lam - 1, k) + qpow(mod - 1, k) * (lam - 1)) % mod *
			qpow((lam - 1 + (lam - 2) * (lam - 2)) % mod,
 (n - 1) * k) % mod);
		}
	}
	return 0;
}

详细

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3728kb

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