标签:style blog http color io os ar for strong
题目链接,点击一下 Round#273 Div.2
==================
problem A Initial Bet
==================
很简单,打了两三场的cf第一次在10分钟内过题
判平均数,且注意b为正
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
=====================
max的时候 就是前面m-1组都是1 最后一组是n-(m-1)
min的时候 先平分即每组n/m,然后剩下的n%m平均分到n%m组中,即前(m-n%m)组是n/m,而后面的(n%m)组是(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 }
标签:style blog http color io os ar for strong
原文地址:http://www.cnblogs.com/imLPT/p/4030208.html