10236-the Fibonacci Primes
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=1177
Note that the description of this topic is different from the description of Fibonacci prime on Wikipedia.
The above-highlighted text shows that Fibonacci Prime can be screened with a similar number of primes.
However, the theorem "if b|a, then Fb|fa" can not be introduced if P is prime, then FP is Fibonacci Prime ".
To prove this, we can prove that "if FB|FA, then B|a" (see "Specific mathematics" P247 and "proofs that really Art of count:the combinatorial" Proof)
Complete code:
/*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/=, a/=;
if (!vis[i])
{
tmp = B;
while (TMP >= 1E9) TMP/=;
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[n));
return 0;
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/