HDU

题目链接

题目大意

  略

解题思路

  套公式

代码

const int maxn = 1e4+10;
const int maxm = 1e6+10;
ll f[100] = {0, 1, 1};
int main() {
	int n;
	for (int i = 3; i<=20; ++i) f[i] = f[i-1]+f[i-2];
	while(cin >> n){
		if (n<21) cout << f[n] << endl;
		else {
			double t = -0.5*log(5.0)/log(10.0) + ((double)n)*log((sqrt(5.0)+1.0)/2.0)/log(10.0);
			t -= floor(t);
			t = pow(10.0, t);
			while(t < 1000) t *= 10;
			cout << (int)t << endl;
		}
	}
	return 0;
} 
原文地址:https://www.cnblogs.com/shuitiangong/p/14383265.html