fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin>>t;
  7. while(t--){
  8. int n;
  9. cin>>n;
  10. int a[n];
  11. for(int i=0;i<n;i++)
  12. cin>>a[i];
  13. int max=0,x;
  14. for(int i=0;i<n;i++){
  15.  
  16. for(int j=i;j<n;j++){
  17. x=a[i]%a[j];
  18. if(x>max)
  19. max=x;
  20. }
  21. }
  22. cout<<max<<endl;
  23. }
  24. return 0;
  25. }
Runtime error #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout

Standard output is empty