【CPE】一顆星選集(Part 13) | C++

更新於 發佈於 閱讀時間約 7 分鐘

Satellites

題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1162

#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://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1583

中文題目: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://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1183

中文題目: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;
}



留言
avatar-img
留言分享你的想法!
avatar-img
Jim的沙龍
1會員
31內容數
Jim的沙龍的其他內容
2025/08/14
2 the 9s 題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1863 中文題目:https://zerojudge.tw/S
2025/08/14
2 the 9s 題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1863 中文題目:https://zerojudge.tw/S
2025/08/14
All You Need Is Love! 題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1134 中文題目:https://z
2025/08/14
All You Need Is Love! 題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1134 中文題目:https://z
2025/08/14
Parity 題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1872 中文題目:https://zerojudge.tw/Sho
2025/08/14
Parity 題目:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1872 中文題目:https://zerojudge.tw/Sho
看更多