題目
s = sum, d = absolute difference
two final scores, largest first (or impossible)
解法
s = a + b
d = a – b
s + d = 2a
s – d = 2b
#include <iostream>
#define ll long long
using namespace std;
int main(){
int S;
ll D;
while(cin >> S >> D){
int now = S;
while(D > 0){
D -= now;
if(D > 0) now++;
}
cout << now << 'n';
}
}👉 回到:【CPE大學程式能力檢定】目錄