結果

問題 No.3358 逆数の小数部分
コンテスト
ユーザー Hydrogen332
提出日時 2025-11-15 19:24:37
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 507 bytes
コンパイル時間 3,202 ms
コンパイル使用メモリ 276,284 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-11-15 19:24:42
合計ジャッジ時間 4,103 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	
	string X;
	cin >> X;
	
	ll A = 0, B = 1;
	bool find = false;
	for (char c : X) {
		if (c == '.') find = true;
		else {
			A *= 10;
			A += c - '0';
			if (find) B *= 10;
		}
	}
	
	int ans = 0;
	while (true) {
		++ans;
		ll temp = A;
		A = B % A;
		B = temp;
		if (A == 0) break;
	}
	cout << ans << '\n';
}
0