# Codeforces Round #382 (Div. 2)解题报告

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <cstring>
#include <ctime>
#include <vector>
#define inf 1e9
#define ll long long
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=k;i>=j;i--)
using namespace std;
inline void read(int &tx){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  tx=x*f; }
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  }
inline void writeln(ll x){write(x);puts("");}
using namespace std;
int n,n1,n2,a[400001];
double ans;
inline bool cmp(int x,int y){return x>y;}
int main()
{
scanf("%d%d%d",&n,&n1,&n2);
if(n1>n2)	swap(n1,n2);
For(i,1,n)	scanf("%d",&a[i]);
sort(a+1,a+n+1,cmp);
For(i,1,n1)	ans+=(double)a[i]/n1;
For(i,n1+1,n1+n2)	ans+=(double)a[i]/n2;
printf("%.8lf",ans);
}


C. Tennis Championship

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <cstring>
#include <ctime>
#include <vector>
#define inf 1e9
#define ll long long
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=k;i>=j;i--)
using namespace std;
inline void read(int &tx){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  tx=x*f; }
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  }
inline void writeln(ll x){write(x);puts("");}
using namespace std;
ll n,f[10001],tot;
int main()
{
scanf("%lld",&n);
f[0]=1;
f[1]=1;
tot=1;
while(1)
{
if(f[tot]>=n)	break;
tot++;
f[tot]=f[tot-1]+f[tot-2];
}
if(f[tot]>n)	tot--;
printf("%lld",tot-1);
}
D. Taxes

lc233大佬太强了orz

？？？？

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <cstring>
#include <ctime>
#include <vector>
#define inf 1e9
#define ll long long
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=k;i>=j;i--)
using namespace std;
inline void read(int &tx){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  tx=x*f; }
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  }
inline void writeln(ll x){write(x);puts("");}
using namespace std;
ll	n;

int main()
{
scanf("%lld",&n);
if(n==2){puts("1");return 0;}
if(n%2==0)	{puts("2");return 0;}
bool flag=1;
For(i,2,sqrt(n)+1)	if(n%i==0)	flag=0;
if(flag==1)	{puts("1");return 0;}
n-=2;
flag=1;
For(i,2,sqrt(n)+1)	if(n%i==0)	flag=0;
if(flag==1)	{puts("2");return 0;}
puts("3");
}

E. Ostap and Tree

1、（t+1）+x<=2*k

2、（t+1）+x>2*k

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <cstring>
#include <ctime>
#include <vector>
#define inf 1e9
#define ll long long
#define For(i,j,k) for(ll i=j;i<=k;i++)
#define Dow(i,j,k) for(ll i=k;i>=j;i--)
using namespace std;
inline void read(ll &tx){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  tx=x*f; }
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  }
inline void writeln(ll x){write(x);puts("");}
using namespace std;
ll mo=1e9+7;

ll poi[10001],F[10001],nxt[10001],f[1001][1001],tmp[1001],ans,n,k,x,y,cnt;
bool vis[1001];
inline void dfs(ll x)
{
vis[x]=1;
f[x][0]=f[x][k+1]=1;
for(ll i=F[x];i;i=nxt[i])
{
ll ne=poi[i];
if(vis[ne])	continue;
dfs(ne);
For(j,0,2*k+1)	tmp[j]=0;
For(j,0,2*k+1)
For(t,0,2*k)
{
if(j+t<=2*k)
tmp[min(j,t+1)]+=f[x][j]*f[ne][t],tmp[min(j,t+1)]%=mo;
else
tmp[max(j,t+1)]+=f[x][j]*f[ne][t],tmp[max(j,t+1)]%=mo;
}
For(j,0,2*k+1)	f[x][j]=tmp[j];
}
}
int  main()
{
dfs(1);
For(i,0,k)	ans+=f[1][i],ans%=mo;
writeln(ans);
}





10-30 176

04-16 863
05-02 174
07-20 1304
03-27 168
08-12 1033
05-15 340