题意:给出一个数n,问n能否是斐波那契数列中数的乘积
先刷选 斐波那契数列,然后就枚举
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <iostream>
using namespace std;
typedef long long LL;
const LL Max = ;
LL num[];
map<LL, bool> m;
void init()
{
queue<LL> q;
m[] = true;
m[] = true;
num[] = ;
num[] = ;
for (int i = ; i < ; i++)
{
num[i] = num[i - ] + num[i - ];
q.push(num[i]);
m[ num[i] ] = true;
}
while (!q.empty())
{
int temp = q.front();
q.pop();
for (int i = ; i < ; i++)
{
LL res = temp * num[i];
if (res > Max)
break;
if (m[ res ])
continue;
m[ res ] = true;
q.push(res);
}
} }
int main()
{
init();
int test, n;
scanf("%d", &test);
while (test--)
{
scanf("%d", &n);
if (m[ n ])
printf("Yes\n");
else
printf("No\n");
}
return ;
}