fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. int a, b;
  7. cin >> a >> b;
  8. int f[1000000];
  9. f[0] = 0;
  10. f[1] = 1;
  11. f[2] = 1;
  12. f[3] = 2;
  13. for(int i = 4; i <= b; i++){
  14. f[i] = f[i-1] + f[i-2];
  15. }
  16. int c = f[a], d = f[b];
  17. while(d%=c)swap(c, d);
  18. cout << c;
  19. return 0;
  20. }
Success #stdin #stdout 0s 4504KB
stdin
5 10
stdout
5