Codeforces Gym101606 I.I Work All Day (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
I I Work All Day
这个题就是取模找最小的。
代码:
1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<cmath>
5 #include<queue>
6 #include<set>
7 #include<algorithm>
8 #include<map>
9 #define maxn 200005
10 using namespace std;
11 int main()
12 {
13 int n,flag,t;
14 int a[maxn];
15 while(cin>>n)
16 {
17 for(int i=0;i<n;i++)
18 cin>>a[i];
19 cin>>t;
20 int min=100005;
21 for(int i=0;i<n;i++)
22 {
23 int ans=t%a[i];
24 if(ans<min){min=ans;flag=a[i];}
25 }
26 cout<<flag<<endl;
27 }
28 return 0;
29 }