#include <cstdio>
#include <set>
using std::set;
const int FIB_SIZE = 46;
int fibs[FIB_SIZE];
set<int> products;
int main()
{
fibs[0] = 0;
fibs[1] = 1;
for (int i = 2; i < FIB_SIZE; i++)
fibs[i] = fibs[i - 2] + fibs[i - 1];
for (int i1 = 0; i1 < FIB_SIZE; i1++)
for (int i2 = 0; i2 < FIB_SIZE; i2++)
{
long long int product = (long long int)fibs[i1] * fibs[i2];
if (product < 1200000000)
products.insert((int)product);
}
int t;
scanf("%d", &t);
while (t--)
{
int a;
scanf("%d", &a);
if (products.find(a) != products.end())
printf("TAK\n");
else
printf("NIE\n");
}
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #include <cstdio> #include <set> using std::set; const int FIB_SIZE = 46; int fibs[FIB_SIZE]; set<int> products; int main() { fibs[0] = 0; fibs[1] = 1; for (int i = 2; i < FIB_SIZE; i++) fibs[i] = fibs[i - 2] + fibs[i - 1]; for (int i1 = 0; i1 < FIB_SIZE; i1++) for (int i2 = 0; i2 < FIB_SIZE; i2++) { long long int product = (long long int)fibs[i1] * fibs[i2]; if (product < 1200000000) products.insert((int)product); } int t; scanf("%d", &t); while (t--) { int a; scanf("%d", &a); if (products.find(a) != products.end()) printf("TAK\n"); else printf("NIE\n"); } return 0; } |
English