# AtCoder Beginner Contest 207

2021-06-26 23:02:28  阅读：231  来源： 互联网

A

#include<bits/stdc++.h>
#define I inline
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define re register
#define ll long long
#define db double
#define N 20000
#define mod 1000000007
#define eps (1e-7)
#define U unsigned int
#define IT set<ques>::iterator
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
using namespace std;
int a[3];
int main(){
scanf("%d%d%d",&a[0],&a[1],&a[2]);sort(a,a+3);printf("%d\n",a[2]+a[1]);
}


B

code:

#include<bits/stdc++.h>
#define I inline
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define re register
#define ll long long
#define db double
#define N 20000
#define mod 1000000007
#define eps (1e-7)
#define U unsigned int
#define IT set<ques>::iterator
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
using namespace std;
ll A,B,C,D;
int main(){
scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
if(C*D-B<=0)printf("-1\n");
else printf("%lld\n",(ll)ceil(A*1.0/(C*D-B)));
}


code:

#include<bits/stdc++.h>
#define I inline
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define re register
#define ll long long
#define db double
#define N 2000
#define mod 1000000007
#define eps (1e-7)
#define U unsigned int
#define IT set<ques>::iterator
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
using namespace std;
int n,m,ans,t;db A[N+5],B[N+5];
int main(){
re int i,j;scanf("%d",&n);for(i=1;i<=n;i++) scanf("%d%lf%lf",&t,&A[i],&B[i]),(t==2)&&(B[i]-=eps),(t==3)&&(A[i]+=eps),(t==4)&&(B[i]-=eps,A[i]+=eps);
for(i=1;i<=n;i++){
for(j=i+1;j<=n;j++) ans+=(max(A[i],A[j])<=min(B[i],B[j]));
}printf("%d\n",ans);
}


D

code:

#include<bits/stdc++.h>
#define I inline
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define re register
#define ll long long
#define db double
#define N 100
#define mod 1000000007
#define eps (1e-5)
#define U unsigned int
#define IT set<ques>::iterator
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
using namespace std;
int n,A[N+5],B[N+5],flag;db nowx,nowy;
struct point{db A,B;}S[N+5],C[N+5];I bool cmp(point x,point y){return x.A==y.A?(x.B<y.B):(x.A<y.A);}
int main(){
freopen("1.in","r",stdin);
re int i,j;scanf("%d",&n);for(i=1;i<=n;i++) scanf("%d%d",&A[i],&B[i]);for(i=1;i<=n;i++) scanf("%lf%lf",&C[i].A,&C[i].B);sort(C+1,C+n+1,cmp);
for(db i=0;i<=360;i+=(5e-4)){nowx=cos(i);nowy=sin(i);
for(j=1;j<=n;j++) S[j].A=A[j]*nowx-B[j]*nowy,S[j].B=A[j]*nowy+B[j]*nowx;sort(S+1,S+n+1,cmp);
flag=0;nowx=S[1].A-C[1].A;nowy=S[1].B-C[1].B;for(j=2;j<=n;j++) if(abs(S[j].A-C[j].A-nowx)>eps||abs(S[j].B-C[j].B-nowy)>eps){flag=1;break;}
if(!flag){printf("Yes\n");return 0;}
}printf("No\n");
}


E

code:

#include<bits/stdc++.h>
#define I inline
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define re register
#define ll long long
#define db double
#define N 3000
#define mod 1000000007
#define eps (1e-7)
#define U unsigned int
#define IT set<ques>::iterator
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
using namespace std;
int n;ll A[N+5],dp[N+5][N+5],Sum[N+5],G[N+5],Ans;
int main(){
freopen("1.in","r",stdin);
re int i,j;scanf("%d",&n);for(i=1;i<=n;i++)scanf("%lld",&A[i]),Sum[i]=Sum[i-1]+A[i];
for(i=1;i<=n;i++){
memset(G,0,sizeof(G));if(i==1)G[0]=1;for(j=1;j<=n;j++)
dp[j][i]=G[Sum[j]%i],G[Sum[j]%i]=(dp[j][i-1]+G[Sum[j]%i])%mod;
}
for(i=1;i<=n;i++)Ans+=dp[n][i];printf("%lld\n",Ans%mod);
}


F

code:

#include<bits/stdc++.h>
#define I inline
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define re register
#define ll long long
#define db double
#define N 3000
#define mod 1000000007
#define eps (1e-7)
#define U unsigned int
#define IT set<ques>::iterator
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
using namespace std;
int n,x,y,siz[N+5],in[N+5];ll dp[N+5][N+5][3];
struct yyy{int to,z;};
I void dfs(int x,int last){
siz[x]=dp[x][0][0]=dp[x][1][1]=1;yyy tmp;re int i,j,h;for(i=s.h[x];i;i=tmp.z){
tmp=s.f[i];if(tmp.to==last) continue;dfs(tmp.to,x);for(j=0;j<=siz[tmp.to];j++) dp[tmp.to][j][0]%=mod,dp[tmp.to][j][1]%=mod,dp[tmp.to][j][2]%=mod;;
for(j=siz[x];~j;j--){dp[x][j][0]%=mod;dp[x][j][1]%=mod;dp[x][j][2]%=mod;
for(h=siz[tmp.to];~h;h--){
if(h)dp[x][j+h][0]+=dp[x][j][0]*(dp[tmp.to][h][0]+dp[tmp.to][h][2])%mod;
if(h)dp[x][j+h][1]+=dp[x][j][1]*(dp[tmp.to][h][1]+dp[tmp.to][h][2])%mod;
dp[x][j+h+1][1]+=dp[x][j][1]*dp[tmp.to][h][0]%mod;
if(h)dp[x][j+h][2]+=dp[x][j][2]*(dp[tmp.to][h][1]+dp[tmp.to][h][0]+dp[tmp.to][h][2])%mod;
dp[x][j+h+1][2]+=(dp[x][j][0]*dp[tmp.to][h][1])%mod;
}dp[x][j][1]=0;
} siz[x]+=siz[tmp.to];
}
}
int main(){
freopen("1.in","r",stdin);