假设:
- 两张卡牌A,B,其初始数字为n
- 开始对A操作,值为x
最优情况:
A | B |
---|---|
n-x | n |
n-x | x |
n-2x | x |
所以:
-
答案应为为 n - x
-
而 0 <= x <= [n / 2]
-
故答案应为 n - [n / 2]
正解:
void solve(){
int n;
cin >> n;
cout << (n - n / 2);
}
A | B |
---|---|
n-x | n |
n-x | x |
n-2x | x |
答案应为为 n - x
而 0 <= x <= [n / 2]
故答案应为 n - [n / 2]
void solve(){
int n;
cin >> n;
cout << (n - n / 2);
}