Satellites
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
#define PI acos(0.0)*2.0
int main() {
double r, s, a;
string unit;
double chord, arc;
r = 6440.0;
while (cin >> s >> a >> unit){
if (unit == "min") a /= 60.0;
if (a > 180.0) a = 360.0 - a;
chord = (r+s) * cos((90.0 - a/2.0)/ 180.0 * PI) * 2.0;
arc = 2.0 * PI * (r+s) * a / 360.0;
cout << fixed << setprecision(6) << arc << " " << chord << "\n";
}
return 0;
}
Can You Solve It?
中文題目:https://zerojudge.tw/ShowProblem?problemid=i859#include <iostream>
using namespace std;
int main() {
int T;
long long x, y, n, step1, step2;
cin >> T;
for (int Case = 1; Case <= T; Case++){
cout << "Case " << Case << ": ";
cin >> x >> y;
if (x == 0 && y == 0) step1 = 0;
else {
n = x + y - 1;
step1 = (n * n + 3 * n) / 2 + (x + 1);
}
cin >> x >> y;
n = x + y - 1;
if (x == 0 && y == 0) step2 = 0;
else {
n = x + y - 1;
step2 = (n * n + 3 * n) / 2 + (x + 1);
}
cout << step2 - step1 << "\n";
}
return 0;
}
Fourth Point!!
中文題目:https://zerojudge.tw/ShowProblem?problemid=e512
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
double x[4], y[4];
double x1, y1, x2, y2, x3, y3;
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]){
if (x[1] == x[2] && y[1] == y[2]){
x1 = x[0]; y1 = y[0];
x2 = x[1]; y2 = y[1];
x3 = x[3]; y3 = y[3];
} else if (x[0] == x[2] && y[0] == y[2]){
x1 = x[1]; y1 = y[1];
x2 = x[0]; y2 = y[0];
x3 = x[3]; y3 = y[3];
} else if (x[0] == x[3] && y[0] == y[3]){
x1 = x[1]; y1 = y[1];
x2 = x[0]; y2 = y[0];
x3 = x[2]; y3 = y[2];
} else if (x[1] == x[3] && y[1] == y[3]){
x1 = x[0]; y1 = y[0];
x2 = x[1]; y2 = y[1];
x3 = x[2]; y3 = y[2];
}
cout << fixed << setprecision(3)
<< x3 + x1 - x2 << " " << y3 + y1 - y2 << "\n";
}
return 0;
}