• BZOJ3713: [PA2014]Iloczyn


    3713: [PA2014]Iloczyn

    Time Limit: 1 Sec  Memory Limit: 128 MB
    Submit: 206  Solved: 112
    [Submit][Status]

    Description

    斐波那契数列的定义为:k=0或1时,F[k]=k;k>1时,F[k]=F[k-1]+F[k-2]。数列的开头几项为0,1,1,2,3,5,8,13,21,34,55,…你的任务是判断给定的数字能否被表示成两个斐波那契数的乘积。

    Input

    第一行包含一个整数t(1<=t<=10),表示询问数量。接下来t行,每行一个整数n_i(0<=n_i<=10^9)。

    Output

    输出共t行,第i行为TAK(是)或NIE(否),表示n_i能否被表示成两个斐波那契数的乘积。

    Sample Input

    5
    5
    4
    12
    11
    10

    Sample Output

    TAK
    TAK
    NIE
    NIE
    TAK

    HINT

     

    Source

    题解:
    fib数,呵呵,10^9太小了,10^9内只有45个,暴力就行了。。。
    代码:
     1 #include<cstdio>
     2 #include<cstdlib>
     3 #include<cmath>
     4 #include<cstring>
     5 #include<algorithm>
     6 #include<iostream>
     7 #include<vector>
     8 #include<map>
     9 #include<set>
    10 #include<queue>
    11 #include<string>
    12 #define inf 1000000000
    13 #define maxn 500+100
    14 #define maxm 500+100
    15 #define eps 1e-10
    16 #define ll long long
    17 #define pa pair<int,int>
    18 #define for0(i,n) for(int i=0;i<=(n);i++)
    19 #define for1(i,n) for(int i=1;i<=(n);i++)
    20 #define for2(i,x,y) for(int i=(x);i<=(y);i++)
    21 #define for3(i,x,y) for(int i=(x);i>=(y);i--)
    22 #define mod 1000000007
    23 using namespace std;
    24 inline ll read()
    25 {
    26     ll x=0,f=1;char ch=getchar();
    27     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    28     while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    29     return x*f;
    30 }
    31 ll n,m,f[100];
    32 int main()
    33 {
    34     freopen("input.txt","r",stdin);
    35     freopen("output.txt","w",stdout);
    36     f[0]=0;f[1]=1;
    37     for(n=2;n<=44;n++)f[n]=f[n-1]+f[n-2];
    38     m=read();
    39     while(m--)
    40     {
    41         ll x=read(),flag=0;
    42         for0(i,n)
    43          for0(j,n)
    44           if(f[i]*f[j]==x){flag=1;break;}
    45         if(flag)printf("TAK
    ");else printf("NIE
    ");
    46     }
    47     return 0;
    48 }
    View Code
  • 相关阅读:
    python邮件之附件
    python3.5之smtp
    一台Linux上搭建两个tomcat
    mysql 初探(一)
    python监视mysql最大连接数
    P3658 [USACO17FEB]Why Did the Cow Cross the Road III P cdq分治
    P4793 [AHOI2008]矩形藏宝地 cdq分治 线段树
    P2487 [SDOI2011]拦截导弹 线段树 cdq分治
    P3157 [CQOI2011]动态逆序对 cdq分治
    P4169 [Violet]天使玩偶/SJY摆棋子 cdq分治
  • 原文地址:https://www.cnblogs.com/zyfzyf/p/4004166.html
Copyright © 2020-2023  润新知