結果
問題 | No.1464 Number Conversion |
ユーザー |
![]() |
提出日時 | 2021-04-02 23:49:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 829 bytes |
コンパイル時間 | 2,080 ms |
コンパイル使用メモリ | 170,748 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-23 22:58:47 |
合計ジャッジ時間 | 2,997 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 WA * 10 |
ソースコード
#include<bits/stdc++.h> using namespace std; using u64 = uint_least64_t; using s64 = int_least64_t; using ll = uint_least64_t; int main(){ string xs, us, ds; cin >> xs; int pos = xs.find("."); // cout << pos << endl; if (pos < 0){ cout << xs << "/1" << endl; return 0; } us = xs.substr(0, pos); // cout << "us=" << us << endl; ds = xs.substr(pos + 1, xs.length() - pos-1); // cout << "ds=" << ds << endl; string ts = us + ds; // cout << "ts=" << ts << endl; u64 tsi = atoi(ts.c_str()); if (tsi == 0){ cout << "0/1" << endl; return 0; } u64 b = pow(10, ds.length()); if (tsi % 2 == 0){ tsi /= 2; b /= 2; } if (tsi % 5 == 0){ tsi /= 5; b /= 5; } cout << tsi << "/"<< b << endl; return 0; }