Odd Sum
中文題目:https://zerojudge.tw/ShowProblem?problemid=c022
#include <iostream>
using namespace std;
int main(){
int T;
cin >> T;
for (int i = 1; i <= T; i++) {
int a, b;
cin >> a >> b;
if (a % 2 == 0) {
a += 1;
}
if (b % 2 == 0) {
b -= 1;
}
int num=(b-a)/2+1;
int total;
total=(a+b)/2*num;
cout << "Case " << i << ": ";
cout << (a + b) / 2 * ((b - a) / 2 + 1) << "\n";
}
return 0;
}
Beat the Spread!
題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1753中文題目:https://zerojudge.tw/ShowProblem?problemid=c004
#include <iostream>
using namespace std;
int main() {
int T, s, d;
cin >> T;
while (T--){
cin >> s >> d;
if ((s + d) % 2 || s < d) cout << "impossible\n";
else {
cout << (s+d)/2 << " " << (s-d)/2 << "\n";
}
}
return 0;
}
Symmetric Matrix
中文題目:https://zerojudge.tw/ShowProblem?problemid=e513
#include <iostream>
using namespace std;
int main() {
int T, n;
char ch;
cin >> T;
for (int Case = 1; Case <= T; Case++){
cin >> ch >> ch >> n;
long long a[n][n];
bool flag = true;
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
cin >> a[i][j];
if (a[i][j] < 0) flag = false;
}
}
cout << "Test #" << Case << ": ";
if (!flag){
cout << "Non-symmetric.\n";
continue;
}
for (int i = 0; i <= n/2; i++){
for (int j = 0; j < n-i; j++){
if (a[i][j] != a[n-1-i][n-1-j]){
flag = false;
break;
}
}
}
if (flag) cout << "Symmetric.\n";
else cout << "Non-symmetric.\n";
}
return 0;
}