# Beat the Spread! 題目連結 ## 中文簡述 一開始先輸入一個整數N,代表有N筆資料 在每一筆資料中有想某兩個數字相加的和`s`和相減差的絕對值`d`,輸出可能的分數,如果沒有可能的分數,輸出`impossible` ## solution: ``` #include<bits/stdc++.h> using namespace std; int main() { int n,s,d,i;; while(cin>>n) { for(i=0;i<n;i++) { cin>>s>>d; int a=(s+d)/2,b=(s-d)/2; if((s+d)%2 or s<d) { cout<<"impossible"<<endl; } else { cout<<(s+d)/2<<" "<<(s-d)/2<<endl; } } } } ``` ###### tags: `UVA` 回目錄 [學習筆記](/gIBZqAbWTCis7uOPp149gA)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up