刚开始拿到这道题有点懵,但是很快确定了基本的解题方向:r,b,d三个参数,通过其中两个来确定另一个的合理范围,从而确定另一个是否合法。
然后开始造了几个数据,以 2 7 3 为例,可以考虑把2拆成一个一个的,则每个最大可以配一个4(因为1 + 3 == 4),所以对于这个样例,b的最大取值可以是8,所以7是合理的。
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #define LL long long 6 using namespace std; 7 LL a,b,c; 8 int main(){ 9 10 int T; 11 cin>>T; 12 while(T--){ 13 LL a,b,c; 14 cin>>a>>b>>c; 15 if(a>b) swap(a,b); 16 LL d1=a*(c+1); 17 if(b<=d1) cout<<"YES"<<endl; 18 else cout<<"NO"<<endl; 19 } 20 21 22 23 return 0; 24 25 }
一定要记得看数据范围!!!这次就是忘了开long long 导致浪费了很长时间debug
Educational Codeforces Round 108 (Rated for Div. 2) A. Red and Blue Beans
原文:https://www.cnblogs.com/talk-sea/p/14720381.html