[Luogu] P9779 题解

P9779 题解

观察样例,发现 \(n = 15\) 时输出的是 \(32767\),一眼丁真,鉴定为 \(2^{15}-1\);同时发现前面的样例也都符合 \(2^n-1\),于是得到结论:输出 \(2^n-1\)

#include <bits/stdc++.h>

using namespace std;

int n;

int main() {
	
	cin >> n;
	cout << (1 << n) - 1;//等价于 (int)pow(2, n) - 1
	
	return 0;
}
posted @ 2023-11-17 20:52  FurippuWRY  阅读(27)  评论(0)    收藏  举报