View Code of Problem 3834

#include <bits/stdc++.h>
using namespace std;
// 我人傻了
int main() {
	int n, i;
	long long a[31];
	a[0] = 0;
	a[1] = 2;
	a[2] = 5;
	for (i = 3; i < 31; i++) {
		a[i] = a[i - 1] * 3 - 1;
	}
	while (cin >> n) {
		cout << a[n] << endl;
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 3834