結果
| 問題 |
No.1464 Number Conversion
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-01 01:58:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 582 bytes |
| コンパイル時間 | 496 ms |
| コンパイル使用メモリ | 68,496 KB |
| 最終ジャッジ日時 | 2025-01-21 04:58:03 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 29 |
ソースコード
#include <iostream>
#include <numeric>
#include <string>
using namespace std;
using lint = long long;
void solve() {
string s;
cin >> s;
lint num = 0, den = 0;
for (auto c : s) {
if (c == '.') {
den = 1;
} else {
int d = c - '0';
num = num * 10 + d;
den *= 10;
}
}
if (den == 0) den = 1;
auto g = gcd(num, den);
num /= g, den /= g;
cout << num << "/" << den << "\n";
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
solve();
return 0;
}