結果

問題 No.3358 逆数の小数部分
コンテスト
ユーザー SnowBeenDiding
提出日時 2025-11-14 22:46:13
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,092 bytes
コンパイル時間 5,138 ms
コンパイル使用メモリ 335,156 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-11-14 22:46:20
合計ジャッジ時間 6,244 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/all>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace atcoder;
using namespace std;

typedef long long ll;

int ans;

__int128 mygcd(__int128 a, __int128 b) {
    ans++;
    if (a == b) return 0;
    if (b == 0) {
        return a;
    } else {
        return mygcd(b, a % b);
    }
}

__int128 f(int k) {
    __int128 x = 1;
    rep(i, 0, k) x *= 10;
    return x;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(12);
    ans = 0;
    ll a, b;
    char c;
    cin >> a >> c;
    if (c == '.')
        cin >> b;
    else {
        b = 0;
    }
    if (a == 1 && b == 0) {
        cout << 1 << endl;
        return 0;
    }
    if (a >= 1) ans++;
    a *= f(to_string(b).size());
    a += b;
    b = f(to_string(b).size());
    while (!(a == 0 || b == 0)) {
        cerr << (ll)a << ' ' << (ll)b << endl;
        if (a >= b) {
            a %= b;
            ans++;
        } else {
            b %= a;
            ans++;
        }
    }
    cout << ans << endl;
}
0