zoukankan      html  css  js  c++  java
  • 打表

    zjut 1176 菲波那契数" - 博客后台管理 - 博客园
    http://i.cnblogs.com/EditPosts.aspx?postid=3887297

    2098分拆素数和

    Problem Description
    把一个偶数拆成两个不同素数的和,有几种拆法呢?

    Input
    输入包含一些正的偶数,其值不会超过10000,个数不会超过500,若遇0,则结束。

    Output
    对应每个偶数,输出其拆成不同素数的个数,每个结果占一行。

    Sample Input
    30
    26
    0

    Sample Output
    3
    2

    ****************************************
    **************************************************************************

    #include <iostream>
    using namespace std;
    #define N 10000
    int bz[N]={1,1,0,0,1,0};


    void init()
    {int i,j;
    for(i=2;i<=N;i++)
    for(j=2;i*j<=N;j++)
    bz[i*j]=1;

    }

    int main()
    {
    int n,i,s;
    init();
    while(cin>>n,n)
    {
    s=0;
    for(i=2;i<n/2;i++)
    if(bz[i]==0&&bz[n-i]==0) s++;
    cout<<s<<endl;
    }

    }

    超级阶梯

    #include <stdio.h>
    int s;
    int ggt(int x)
    {
    if(x<1) return 0;
    if(x==1) return 1;
    if(x==2) return 2;
    if(x==3) return 3;
    if(x==4) return 5;
    if(x==5) return 8;
    if(x==6) return 13;

    return ggt(x-1)+ggt(x-2);
    }

    int main()
    {

    int i,k,n,m,x;
    scanf("%d",&n);
    while(n--)
    {
    scanf("%d",&m);
    printf("%d ",ggt(m-1));
    }
    }

    #include <stdio.h>
    int s;
    int ggt(int x)
    {
    if(x<1) return 0;
    if(x==1) return 1;
    if(x==2) return 2;
    if(x==3) return 3;
    if(x==4) return 5;
    if(x==5) return 8;
    if(x==6) return 13;

    if(x==39) return 102334155 ;
    return ggt(x-1)+ggt(x-2);
    }

    int main()
    {

    int i,k,n,m,x;
    scanf("%d",&n);
    while(n--)
    {
    scanf("%d",&m);
    printf("%d ",ggt(m-1));
    }
    }


    ******************************************************
    **********************************************************************

    #include <iostream>
    using namespace std;
    int main()
    {
    int t,n,a[40]={0,1,2},i;
    cin>>t;
    while(t--)
    {
    cin>>n;
    for(i=3;i<=n;i++)
    a[i]=a[i-1]+a[i-2];
    cout<<a[n-1]<<endl;
    }
    return 0;
    }


    #include <iostream>
    using namespace std;
    int main()
    {
    int t,n,a[41]={0,0,1,2},i;
    cin>>t;
    while(t--)
    {
    cin>>n;
    for(i=4;i<=n;i++)
    a[i]=a[i-1]+a[i-2];
    cout<<a[n]<<endl;
    }
    return 0;
    }


  • 相关阅读:
    【python cookbook】【字符串与文本】3.利用shell通配符做字符串匹配
    【python cookbook】【字符串与文本】2.在字符串的开头或结尾处做文本匹配
    python any()和all()用法
    【python cookbook】【字符串与文本】1.针对任意多的分隔符拆分字符串
    python编码:gbk编码与解码
    [转]ASP.NET MVC 5– 使用Wijmo MVC 5模板1分钟创建应用
    [转]ASP.NET MVC 5
    [转]ASP.NET MVC 5
    [转]ASP.NET MVC 5
    [转]ASP.NET MVC 5
  • 原文地址:https://www.cnblogs.com/2014acm/p/3901395.html
Copyright © 2011-2022 走看看