Niestety, nie byliśmy w stanie w pełni poprawnie wyświetlić tego pliku, ponieważ nie jest zakodowany w UTF-8.
Możesz pobrać ten plik i spróbować otworzyć go samodzielnie.
/// *** Naglowki autorstwa Piotra Stanczyka #include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <algorithm> #include <ctime> #include <fstream> #include <set> #define FOR(x, b, e) for(int x = b; x <= (e); ++x) #define FORD(x, b, e) for(int x = b; x >= (e); � �x) #define REP(x, n) for(int x = 0; x < (n); ++x) #define VAR(v, n) typeof(n) v = (n) #define ALL(c) (c).begin(), (c).end() #define SIZE(x) ((int)(x).size()) #define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i) #define PB push_back #define ST first #define ND second using namespace std; const int size = 2000; vector <long long int> F(size);//, Q(1000000000); int quantity; struct Pair { long long int nr; bool pr; }; struct cmp { // czy a jest mniejsze od b bool operator() (const Pair &a, const Pair &b) { if (a.nr <= b.nr) return true; if (a.nr > b.nr) return false; //return a.pr<b.pr; } }; set <Pair, cmp> product; /*struct cmp2 { // czy a jest mniejsze od b bool operator() (const int &a, const int &b) { if (a <= b) return true; if (a > b) return false; //return a.pr<b.pr; } }; set <int, cmp2> product2;*/ set <long long int> product3; void createFibonacci(long long int n) { //product.clear(); //Pair temp; //temp.pr = true; //product3.clear(); if(n > 0) { F[0] = 0; F[1] = 1; quantity = 1; FOR(i, 2, n) { if(F[i-2]+F[i-1] > n)break; F[i] = F[i-2]+F[i-1]; quantity++; } } else { F[0] = 0; quantity = 0; } } vector <long long int> prod(size); void products(long long int q, long long int n) { /*Pair temp, temp2; //set<Pair>::iterator it; temp.pr = false; product.clear(); FOR(i, 0, n) { temp.nr = i; product.insert(temp); } temp2.pr = true;*/ product3.clear(); prod.clear(); FOR(i, 0, q)FOR(j, 0, q) { /*temp.nr = F[i]*F[j]; temp2.nr = F[i]*F[j]; product.erase(product.find(temp)); product.insert(temp);*/ product3.insert(F[i]*F[j]); prod.PB(F[i]*F[j]); } } int main() { ios_base::sync_with_stdio(0); createFibonacci(1000000000); products(quantity, 1000000000); //FOR(i, 0, prod.size()-1)cout<<i<<": "<<prod[i]<<endl; set<Pair>::iterator it; set <long long int>::iterator it3; Pair temp; //FOR(i, 0, quantity)cout<<"F["<<i<<"] = "<<F[i]<<endl; long long int t, n; bool check; cin>>t; REP(x, t) { cin>>n; //createFibonacci(n); //FOR(i, 0, quantity) //temp.nr = n; //temp.pr = true; //it = product.find(temp); //if(it->pr)cout<<"TAK\n"; //else cout<<"NIE\n"; //it3 = product3.find(n); //cout<<*it3<<endl; /*if(*it3 == 0)cout<<"NIE\n"; else cout<<"TAK\n";(*/ check = false; FOREACH(i, prod)if(*i == n) { check = true; break; } if(check)cout<<"TAK\n"; else cout<<"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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | /// *** Naglowki autorstwa Piotra Stanczyka #include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <algorithm> #include <ctime> #include <fstream> #include <set> #define FOR(x, b, e) for(int x = b; x <= (e); ++x) #define FORD(x, b, e) for(int x = b; x >= (e); � �x) #define REP(x, n) for(int x = 0; x < (n); ++x) #define VAR(v, n) typeof(n) v = (n) #define ALL(c) (c).begin(), (c).end() #define SIZE(x) ((int)(x).size()) #define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i) #define PB push_back #define ST first #define ND second using namespace std; const int size = 2000; vector <long long int> F(size);//, Q(1000000000); int quantity; struct Pair { long long int nr; bool pr; }; struct cmp { // czy a jest mniejsze od b bool operator() (const Pair &a, const Pair &b) { if (a.nr <= b.nr) return true; if (a.nr > b.nr) return false; //return a.pr<b.pr; } }; set <Pair, cmp> product; /*struct cmp2 { // czy a jest mniejsze od b bool operator() (const int &a, const int &b) { if (a <= b) return true; if (a > b) return false; //return a.pr<b.pr; } }; set <int, cmp2> product2;*/ set <long long int> product3; void createFibonacci(long long int n) { //product.clear(); //Pair temp; //temp.pr = true; //product3.clear(); if(n > 0) { F[0] = 0; F[1] = 1; quantity = 1; FOR(i, 2, n) { if(F[i-2]+F[i-1] > n)break; F[i] = F[i-2]+F[i-1]; quantity++; } } else { F[0] = 0; quantity = 0; } } vector <long long int> prod(size); void products(long long int q, long long int n) { /*Pair temp, temp2; //set<Pair>::iterator it; temp.pr = false; product.clear(); FOR(i, 0, n) { temp.nr = i; product.insert(temp); } temp2.pr = true;*/ product3.clear(); prod.clear(); FOR(i, 0, q)FOR(j, 0, q) { /*temp.nr = F[i]*F[j]; temp2.nr = F[i]*F[j]; product.erase(product.find(temp)); product.insert(temp);*/ product3.insert(F[i]*F[j]); prod.PB(F[i]*F[j]); } } int main() { ios_base::sync_with_stdio(0); createFibonacci(1000000000); products(quantity, 1000000000); //FOR(i, 0, prod.size()-1)cout<<i<<": "<<prod[i]<<endl; set<Pair>::iterator it; set <long long int>::iterator it3; Pair temp; //FOR(i, 0, quantity)cout<<"F["<<i<<"] = "<<F[i]<<endl; long long int t, n; bool check; cin>>t; REP(x, t) { cin>>n; //createFibonacci(n); //FOR(i, 0, quantity) //temp.nr = n; //temp.pr = true; //it = product.find(temp); //if(it->pr)cout<<"TAK\n"; //else cout<<"NIE\n"; //it3 = product3.find(n); //cout<<*it3<<endl; /*if(*it3 == 0)cout<<"NIE\n"; else cout<<"TAK\n";(*/ check = false; FOREACH(i, prod)if(*i == n) { check = true; break; } if(check)cout<<"TAK\n"; else cout<<"NIE\n"; } return 0; } |