题解移步至: (斜眼笑)
A:
1 #include2 #include 3 #include 4 5 using namespace std; 6 7 int n; 8 9 int main()10 {11 scanf("%d",&n);12 int max=0;13 long long sum=0;14 for (int a=1;a<=n;a++)15 {16 int v;17 scanf("%d",&v);18 if (v>max) max=v;19 sum+=v;20 }21 sum=(sum-1)/(n-1)+1;22 if (sum>max) printf("%I64d\n",sum);23 else printf("%d\n",max);24 25 return 0;26 }
B:
1 #include2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 const int maxn=100010; 9 const long long INF=100000000000000ll;10 11 int n,en,q[maxn],f[maxn];12 13 long long z[maxn],minv[maxn],least[maxn];14 15 struct edge16 {17 int e;18 edge *next;19 }*v[maxn],ed[maxn<<1];20 21 void add_edge(int s,int e)22 {23 en++;24 ed[en].next=v[s];v[s]=ed+en;v[s]->e=e;25 }26 27 long long gcd(long long a,long long b)28 {29 if (!b) return a;30 else return gcd(b,a%b);31 }32 33 int main()34 {35 scanf("%d",&n);36 long long ans=0;37 for (int a=1;a<=n;a++)38 scanf("%I64d",&z[a]),ans+=z[a];39 for (int a=1;a next)52 if (e->e!=1 && !f[e->e])53 {54 f[e->e]=now;55 q[++tail]=e->e;56 }57 }58 for (int a=n;a>=1;a--)59 {60 int now=q[a];61 minv[now]=INF;62 least[now]=1;63 int tot=0;64 for (edge *e=v[now];e;e=e->next)65 if (e->e!=f[now])66 {67 tot++;68 minv[now]=min(minv[now],minv[e->e]*least[e->e]);69 least[now]=least[now]/gcd(least[now],least[e->e])*least[e->e];70 }71 if (!tot) 72 {73 minv[now]=z[now];74 continue;75 }76 if (least[now]) minv[now]=minv[now]/least[now];77 else minv[now]=0;78 least[now]*=tot;79 }80 printf("%I64d\n",ans-least[1]*minv[1]);81 82 return 0;83 }
C:
1 #include2 #include 3 #include 4 #include 5 #include 6 #include 7 8 using namespace std; 9 10 const int maxn=100010;11 const int maxs=350;12 13 int n,m,q,delta[maxn][maxs],num[maxn],to[maxn];14 15 long long z[maxn],res[maxs],col[maxs];16 17 bool use[maxs][maxn];18 19 char s[4];20 21 vector y[maxn];22 23 int main()24 {25 scanf("%d%d%d",&n,&m,&q);26 for (int a=1;a<=n;a++)27 scanf("%I64d",&z[a]);28 int limit=0;29 for (int a=1;a<=m;a++)30 {31 scanf("%d",&num[a]);32 for (int b=1;b<=num[a];b++)33 {34 int v;35 scanf("%d",&v);36 y[a].push_back(v);37 }38 limit+=num[a];39 }40 limit=(int)(sqrt(limit));41 int cnt=0;42 for (int a=1;a<=m;a++)43 if (num[a]>limit)44 {45 to[a]=++cnt;46 for (int b=0;b
D:
1 #include2 #include 3 #include 4 5 using namespace std; 6 7 #define inc(a,b) {a+=b;if (a>=mo) a-=mo;} 8 9 const int maxn=3010;10 const int mo=1000000007;11 12 int n,m,f[maxn][maxn];13 14 char s[maxn][maxn];15 16 int solve(int x1,int y1,int x2,int y2)17 {18 memset(f,0,sizeof(f));19 f[x1][y1]=1;20 for (int a=x1;a<=x2;a++)21 for (int b=y1;b<=y2;b++)22 if (s[a][b]=='.')23 {24 inc(f[a+1][b],f[a][b]);25 inc(f[a][b+1],f[a][b]);26 }27 else f[a][b]=0;28 return f[x2][y2];29 }30 31 int main()32 {33 scanf("%d%d",&n,&m);34 for (int a=1;a<=n;a++)35 scanf("%s",s[a]+1);36 printf("%d\n",(int)((((long long)solve(1,2,n-1,m)*solve(2,1,n,m-1)-(long long)solve(1,2,n,m-1)*solve(2,1,n-1,m))%mo+mo)%mo));37 38 return 0;39 }