UVa 10236 the Fibonacci Primes: Fibonacci primes

Source: Internet
Author: User
Tags printf time limit

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.