Click round #273 div.2.
============================
Problem A initial bet
============================
It's easy. For the first time, I had a question with CF in 10 minutes.
Judge the average, and note that B is positive
1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int res = 0,n; 6 for(int i = 0; i < 5; i++) 7 { 8 cin>>n; 9 res += n;10 }11 int b = res / 5;12 if(res % 5 == 0 && b)13 cout<<b<<endl;14 else cout<<"-1"<<endl;15 return 0;16 }
==================================
Problem B random teams
==================================
When Max is used, M-1 group are m-1)
In min, the split is equal to N/m in each group, and the remaining n % m is evenly distributed to N % m, that is, before (m-N % m) the Group is N/m, and the (N % m) group is (N/m + 1)
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 long long pan(long long x) 5 { 6 return x*(x-1)/2; 7 } 8 int main() 9 {10 //freopen("input.txt","r",stdin);11 long long n,m;12 long long kmin,kmax;13 cin>>n>>m;14 kmax = pan(n-m+1);15 kmin = (m - (n%m))*pan(n/m) + (n%m)*pan(n/m+1);16 cout<<kmin<<" "<<kmax<<endl;17 18 return 0;19 }
======================================
Problem C table decorations
======================================
1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 long long a[3]; 5 6 int main() 7 { 8 scanf("%d%d%d",&a[0],&a[1],&a[2]); 9 sort(a,a+3);10 printf("%d\n",min(a[0]+a[1],(a[0]+a[1]+a[2])/3));11 return 0;12 }
Cf round #273 div.2