
附上AC代码:
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
const double PI = 3.14159265;
const double E = 2.71828182846;
LL num[31] = {1, 0, 3, 0};
void init();
int main()
{
ios::sync_with_stdio(false);
init();
short n;
while (cin >> n && n != -1)
{
cout << num[n] << endl;
}
return 0;
}
void init()
{
for (int i=4; i<31; i++)
num[i] = 4*num[i-2]-num[i-4];
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/silenceneo/article/details/47679779