結果

問題 No.3358 逆数の小数部分
コンテスト
ユーザー Facade
提出日時 2025-11-14 22:09:13
言語 C++23
(gcc 13.3.0 + boost 1.89.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 396 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,862 ms
コンパイル使用メモリ 278,484 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-11-14 22:09:17
合計ジャッジ時間 3,967 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#include<atcoder/modint>
#define int long long
#define double long double
using namespace std;
const int inf=1e18;
using mint=atcoder::modint;
signed main(){
    double x;cin>>x;
    x*=1e9;
    int u=(int)x;
    int d=1e9;
    int g=gcd(u,d);
    u/=g;
    d/=g;
    int ans=0;
    while(u!=0){
        swap(u,d);
        u%=d;
        ans++;
    }
    cout<<ans<<endl;
}
0