結果

問題 No.1624 三角形の反射
ユーザー ktr216ktr216
提出日時 2021-07-23 22:12:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 936 bytes
コンパイル時間 1,657 ms
コンパイル使用メモリ 164,536 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-15 04:46:52
合計ジャッジ時間 2,474 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;

typedef long long ll;

int gcd(int x, int y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    double a;
    cin >> a;
    int x = 1000, y = 1000 * a;
    int g = gcd(x, y);
    int p = x / g, q = y / g, ans = 0;
    if ((p + q) % 2 == 0) {
        cout << "A";
        ans = -1;
    } else if (p % 2) {
        cout << "B";
        ans = -2;
        if (a > 1) ans--;
    } else {
        cout << "C";
        ans = -2;
        if (a > 1) ans--;
    }
    int s = 0;
    ans += p - 1;
    rep(i, 0, p) {
        int t = s + y, u = s / 1000, v = t / 1000;
        if (u == v) {
            ans++;
        } else {
            ans += v - u;
            ans += v - u - 1;
            if (i % 2 == u % 2) ans++;
            if (i % 2 == v % 2) ans++;
        }
        s = t;
    }
    cout << " " << ans << endl;
}
0