fork(1) download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <set>
  5. #include <cstring>
  6. using namespace std;
  7. int const mx = 6666;
  8. set <unsigned long long> f;
  9. unsigned long long fib[mx + 10];
  10. char s[mx + 1];
  11. int main(){
  12. // freopen("input.txt", "r", stdin);
  13. // freopen("output.txt", "w", stdout);
  14. fib[0] = 0;
  15. fib[1] = 1;
  16. f.insert(1);
  17. f.insert(0);
  18. int i;
  19. for (i = 2; i <= mx; i++){
  20. fib[i] = fib[i - 1] + fib[i - 2];
  21. f.insert(fib[i]);
  22. }
  23. int tc;
  24. cin>>tc;
  25. while (tc--){
  26. unsigned long long n = 0, ten = 10;
  27. cin>>s;
  28. int len = strlen(s);
  29. for (i = 0; i < len; i++){
  30. char q = s[i];
  31. unsigned long long a = q - '0';
  32. n = n * ten + a;
  33. }
  34. if (f.find(n) == f.end()) printf("NO\n");
  35. else printf("YES\n");
  36. }
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0s 3664KB
stdin
1
10256117644121029666
stdout
YES