SSL Week 2 Sat. JZOJ simulation game Group B T1 singlet

Subject to the effect:

Problem-solving ideas:

Can be found, the summit must be n, so consider 1 n 1 1 ∼ n − 1 were placed n the left or right, so the only draw the appropriate answer. So the answer is, 2 n 1 2^{n−1} . Then find the answer quickly enough power

A c c e p t e d   c O d e : Accepted\ code:

#include<cstdio>

using namespace std;

const long long ymw = 1e9 + 7;

long long n;

long long ksm(long long x, long long m) {
	long long ans = 1;
	while (m) {
		if (m & 1) (ans*=x) %= ymw;
		(x*=x) %= ymw;
		m >>= 1;
	}
	return ans;
}

int main() {
	scanf("%lld", &n);
	printf("%lld",ksm(2, n-1) % ymw);
}

Guess you like

Origin blog.csdn.net/qq_39798042/article/details/88366548