Skip to content

Instantly share code, notes, and snippets.

@ateruimashin
Created August 15, 2018 08:03
Show Gist options
  • Save ateruimashin/16a62310f1e738db83779aa3393275b3 to your computer and use it in GitHub Desktop.
Save ateruimashin/16a62310f1e738db83779aa3393275b3 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
int n;
cin>>n;
int a[n];
int max=0;
for(int i=0;i<n;i++){
int tmp;
cin>>tmp;
a[i]=tmp;
if(tmp>max) max=tmp;
}
cout<<"max="<<max<<endl;
int ans=0;
int m=0;
for(int i=1;i<100000*max;i++){
int sum=0;
for(int j=0;j<n;j++){
sum+=i%a[j];
}
if(sum>ans){
ans=sum;
m=i;
}
}
printf("m=%d,ans=%d\n",m,ans);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment