标签:题意 cme col hid img iostream close scanf cst
https://www.cnblogs.com/violet-acmer/p/10201535.html
题解:
这题没什么好说的,读懂题意就会了。
比赛代码:
1 #include<iostream> 2 using namespace std; 3 4 int y,b,r; 5 int Solve() 6 { 7 if(b < 2 || r < 3) 8 return 0; 9 for(int i=y;i >= 1;--i) 10 if(b >= i+1 && r >= i+2) 11 return 3*(i+1); 12 return 0; 13 } 14 int main() 15 { 16 cin>>y>>b>>r; 17 cout<<Solve(); 18 return 0; 19 }
赛后整理代码:
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 int y,b,r; 6 7 int Solve() 8 { 9 if(b >= y+1 && r >= y+2) 10 return 3*(y+1); 11 if(y >= b-1 && r >= b+1) 12 return 3*b; 13 if(b >= r-1 && y >= r-2) 14 return 3*(r-1); 15 return 0; 16 } 17 int main() 18 { 19 scanf("%d%d%d",&y,&b,&r); 20 printf("%d\n",Solve()); 21 return 0; 22 }
Good Bye 2018 A. New Year and the Christmas Ornament
标签:题意 cme col hid img iostream close scanf cst
原文地址:https://www.cnblogs.com/violet-acmer/p/10201543.html