結果
| 問題 |
No.3358 逆数の小数部分
|
| コンテスト | |
| ユーザー |
SnowBeenDiding
|
| 提出日時 | 2025-11-14 22:50:00 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 910 bytes |
| コンパイル時間 | 5,422 ms |
| コンパイル使用メモリ | 335,116 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-11-14 22:50:07 |
| 合計ジャッジ時間 | 6,681 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 18 |
ソースコード
#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;
}
a *= f(to_string(b).size());
a += b;
b = f(to_string(b).size());
cerr << (ll)a << ' ' << (ll)b << endl;
while (!(a == 0 || b == 0)) {
ans++;
swap(a, b);
a %= b;
}
cout << ans << endl;
}
SnowBeenDiding