結果
| 問題 | No.3358 逆数の小数部分 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-14 22:02:50 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 662 bytes |
| 記録 | |
| コンパイル時間 | 2,686 ms |
| コンパイル使用メモリ | 279,668 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-11-14 22:02:55 |
| 合計ジャッジ時間 | 3,788 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 WA * 3 |
ソースコード
#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(){
string x;cin>>x;
reverse(x.begin(),x.end());
int id=0;
while(id<x.size()&&x[id]!='.')id++;
int ans=0;
reverse(x.begin(),x.end());
double u=stold(x);
double d=1;
if(id!=x.size()){
for(int i=0;i<id;i++){
u*=10;
d*=10;
}
}
int up=u;
int down=d;
int g=gcd(up,down);
up/=g;
down/=g;
while(up!=0){
swap(up,down);
up%=down;
ans++;
}
cout<<ans<<endl;
}