fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. int gcd (int a, int b) {
  4. while (a!=0 && b!=0) {
  5. if (a>b) {
  6. a=a%b;
  7. }
  8. else b=b%a;
  9. }
  10. return a+b;
  11. }
  12.  
  13. int main () {
  14. int t, a, b;
  15. cin>>t>>b;
  16. for (int i=2; i<=t; ++i) {
  17. cin>>a;
  18. b=gcd (a, b);
  19. }
  20. cout<<b;
  21. return 0;
  22. }
Time limit exceeded #stdin #stdout 5s 4480KB
stdin
2 5
stdout
Standard output is empty