EOJ Monthly 2018.4
This ECNUOJ monthly competition was not played because the academy had to sing a chorus... so we didn't play. After our class finished singing, we picked up our mobile phone and looked at the questions. I felt that the first five questions were not too difficult (fog).
A. ultmaster's little fans
This question can be transformed into Whether there is a solution, then the problem is very simple, not just with Is there a reason to solve it? Expand Euclid, then the solution is very simple. Judge whether or not An integer multiple of .
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<limits.h>
#include<string.h>
#include<map>
#include<list>
using namespace std;
typedef long long ll;
#define inf int(0x3f3f3f3f)
#define mod int(1e9+7)
#define eps double(1e-6)
#define pi acos(-1.0)
#define lson root << 1
#define rson root << 1 | 1
int n;
int x,y;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>x>>y;
if(n%__gcd(x,y)==0)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
B. Code check
This question is a simple application of STL.
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<limits.h>
#include<string.h>
#include<map>
#include<list>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf int(0x3f3f3f3f)
#define mod int(1e9+7)
#define eps double(1e-6)
#define pi acos(-1.0)
#define lson root << 1
#define rson root << 1 | 1
int n,m,k;
int a[100005];
int b[100005];
unordered_map< int,set<int> > mps;
set<int> s;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m>>k;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<m;i++)
cin>>b[i];
for(int i=1;i<=k;i++)
{
int x,y;
cin>>x>>y;
mps[x].insert(y);
}
if(n!=m)
{
cout<<"No"<<endl;
return 0;
}
else
{
int flag=0;
for(int i=0;i<n;i++)
{
if(a[i]==b[i]||mps[a[i]].find(b[i])!=mps[a[i]].end()||mps[b[i]].find(a[i])!=mps[b[i]].end())
continue;
else
{
flag=1;
break;
}
}
if(flag)
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
}
}
For now, I will write these two water questions first, and the remaining questions will be filled up one after another. The blogger is going to write papers. There are three papers to be submitted next week (╯‵□′)╯︵┻━┻
E. Where is the little fan girl
?
This question is a bit simple, greedily arrange the order according to the maximum benefit per unit time, and then pack a bag, how come there are so few people...
#include<cstdio>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<limits.h>
#include<string.h>
#include<map>
#include<list>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf int(0x3f3f3f3f)
#define mod int(1e9+7)
#define eps double(1e-6)
#define pi acos(-1.0)
#define lson root << 1
#define rson root << 1 | 1
int n,T;
struct edge
{
double a,t;
}mi[100005];
bool cmp(edge x,edge y)
{
return x.a/x.t>y.a/y.t;
}
int dp[100005];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>T;
for(int i=0;i<n;i++)
cin>>mi[i].a>>mi[i].t;
sort(mi,mi+n,cmp);
int Max=0;
for(int i=0;i<n;i++)
{
for(int j=T;j>=mi[i].t;j--)
{
dp[j]=max(dp[j],dp[j-(int)mi[i].t]+(T-j)*(int)mi[i].a);
Max=max(Max,dp[j]);
}
}
cout<<Max<<endl;
}