Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <windows.h>
- using namespace std;
- ifstream fin("file.in");
- ifstream fout("file.out");
- int fib[20], counter;
- void generareFibo(int n)
- {
- counter = 2;
- fib[0] = 1;
- fib[1] = 1;
- for(int i = 2;; i++, counter++)
- {
- fib[i] = fib[i - 1] + fib[i - 2];
- if(fib[i] >= n)
- break;
- }
- }
- bool calc()
- {
- int a, b;
- while(fin >> a >> b)
- {
- if(a < b)
- {
- int aux = a;
- a = b;
- b = aux;
- }
- generareFibo(a);
- for(int i = 0; i < counter; i++)
- {
- if(fib[i] == b)
- {
- if(fib[i + 1] == a)
- cout << "DA";
- else
- cout << "NU";
- cout << endl;
- break;
- }
- if(i == counter - 1)fin >> a >> b;
- cout << "NU" << endl;
- }
- }
- }
- int main()
- {
- calc();
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement