Prince and Princess
南京签到二题,博弈/思维。
https://vjudge.net/contest/412295#problem/H
1.a、b、c是王子一开始知道的。2.只有能够准确确定出才行。
把题目解读成出题人想让你理解的那样就会发现这题很简单。
特判1 0 0直接输出0即可
如果a<=b, b总可以指定一个假公主来与a对峙
如果a>b+c,那么2*(b+c)+1就肯定会有一个出现次数b+c+1的答案就是正确的公主位置。
如果a<=b+c,王子不能确定,输出“NO”。
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int a, b, c;
while(cin >> a >> b >>c){
if(a==1 && b==0 && c==0){
puts("YES");
printf("0\n");
continue;
}
if(a <= b){
cout << "NO" << endl; continue;
}
if(a>b +c){
cout << "YES" << endl <<2*(b+c)+1 << endl;
continue;
}
else{
cout << "NO" << endl; continue;
}
}
}