#25064: 注意非整數解


cooljamesku92@gmail.com (你要不要訂閱一塊沒有影片的餅乾owo)

學校 : 臺北市立大同高級中學
編號 : 87502
來源 : [114.36.182.35]
最後登入時間 :
2021-11-19 20:47:58
c004. 10812 - Beat the Spread! -- UVa10812 | From: [114.24.14.196] | 發表日期 : 2021-04-18 12:12

#include<iostream>

using namespace std;

int main() {

int n, sum, abs, big, small;

cin >> n;

for (int i = 0; i < n; i++) {

cin >> sum >> abs;

big = (sum + abs) / 2;

small = big - abs;

if ((sum + abs) % 2)

cout << "impossible" << endl;

else if (big < 0 || small < 0)

cout << "impossible" << endl;

else

cout << big << " " << small << endl;

}

return 0;

}

 
#33250: Re: 注意非整數解


yp11151111@yphs.tp.edu.tw (901-34)

學校 : 不指定學校
編號 : 197226
來源 : [203.72.178.1]
最後登入時間 :
2024-05-27 17:50:52
c004. 10812 - Beat the Spread! -- UVa10812 | From: [203.72.178.2] | 發表日期 : 2022-12-16 13:27

#include

using namespace std;

int main() {

int n, sum, abs, big, small;

cin >> n;

for (int i = 0; i < n; i++) {

cin >> sum >> abs;

big = (sum + abs) / 2;

small = big - abs;

if ((sum + abs) % 2)

cout << "impossible" << endl;

else if (big < 0 || small < 0)

cout << "impossible" << endl;

else

cout << big << " " << small << endl;

}

return 0;

}



 
#33251: Re: 注意非整數解


yp11151111@yphs.tp.edu.tw (901-34)

學校 : 不指定學校
編號 : 197226
來源 : [203.72.178.1]
最後登入時間 :
2024-05-27 17:50:52
c004. 10812 - Beat the Spread! -- UVa10812 | From: [203.72.178.2] | 發表日期 : 2022-12-16 13:27

#include

using namespace std;

int main() {

int n, sum, abs, big, small;

cin >> n;

for (int i = 0; i < n; i++) {

cin >> sum >> abs;

big = (sum + abs) / 2;

small = big - abs;

if ((sum + abs) % 2)

cout << "impossible" << endl;

else if (big < 0 || small < 0)

cout << "impossible" << endl;

else

cout << big << " " << small << endl;

}

return 0;

}





 
ZeroJudge Forum