UVa 10236 The Fibonacci Primes (斐波那契素数)
2013-11-23 14:49
633 查看
10236 - The Fibonacci Primes
Time limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1177
注意此题的描述和维基百科上Fibonacci Prime的描述不同。
上面加着重符的文字说明:可以用类似素数筛的方式筛出Fibonacci Prime。
但是,定理“若b|a,则fb|fa”并不能推出“若p是质数,则fp是Fibonacci Prime”。
要证明这一点,我们可以证明“若fb|fa,则b|a”(详见《具体数学》P247及《Proofs that Really Count: The Art of Combinatorial Proof》P12)
完整代码:
/*0.022s*/ #include<cstdio> const int maxn = 249450; int fp[22001]; bool vis[maxn]; int main() { long long a = 0, b = 1, tmp, i, j; int n, cp; for (cp = 1, i = 2; cp < 22001; ++i) { tmp = a + b, a = b, b = tmp; if (b >= 1e18) b /= 10, a /= 10; if (!vis[i]) { tmp = b; while (tmp >= 1e9) tmp /= 10; fp[cp++] = tmp; for (j = i * i; j < maxn; j += i) vis[j] = true; } } //printf("%lld\n",i); fp[1] = 2, fp[2] = 3; while (~scanf("%d", &n)) printf("%d\n", fp ); return 0; }
相关文章推荐
- UVA 10236 - The Fibonacci Primes(斐波那契素数)
- UVa 10236 - The Fibonacci Primes(斐波那契素数)
- UVA 10236 The Fibonacci Primes
- uva 10236 The Fibonacci Primes
- uva 10236 - The Fibonacci Primes
- UVA 10236 The Fibonacci Primes
- UVA 10236 The Fibonacci Primes
- UVA10236 斐波那契素数
- Colossal Fibonacci Numbers! 巨大的斐波那契数 UVA - 11582
- The Super Powers UVA - 11752 (素数分解)
- UVa10236 - The Fibonacci Primes
- Colossal Fibonacci Numbers! 巨大的斐波那契数 UVA - 11582
- (斐波那契总结)Write a method to generate the nth Fibonacci number (CC150 8.1)
- Colossal Fibonacci Numbers! 巨大的斐波那契数 UVA - 11582
- UVa 11752 (素数筛选 快速幂) The Super Powers
- Colossal Fibonacci Numbers! 巨大的斐波那契数 UVA - 11582
- UVa1213 - Sum of Different Primes(素数表+DP)
- 习题10-5 UVA - 1213 Sum of Different Primes 不同的素数之和(DP + 素数打表)
- UVA - 11582 Colossal Fibonacci Numbers! 巨大的斐波那契数
- Uva11582 Colossal Fibonacci Numbers! (数论、斐波那契循环节)