結果
問題 | No.1464 Number Conversion |
ユーザー |
|
提出日時 | 2021-04-16 00:46:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,606 bytes |
コンパイル時間 | 3,409 ms |
コンパイル使用メモリ | 164,900 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-02 08:31:28 |
合計ジャッジ時間 | 4,052 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 |
ソースコード
#include <atcoder/all>#include <bitset>#include <fstream>#include <functional>#include <iostream>#include <map>#include <math.h>#include <queue>#include <set>#include <stack>#include <stdio.h>#include <stdlib.h>#include <unordered_map>#include <unordered_set>#include <vector>using namespace std;using namespace atcoder;//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//void input() {}long long gcd(long long a, long long b) {if(b==0){return(a);} else{return(gcd(b, a%b));}}std::pair<long long, long long> input_deci(int d) {assert(d >= 0);std::string r; std::cin >> r;std::string::size_type rs = r.size();std::string::size_type rp = r.find('.');long long r_inte = std::stoll(r.substr(0, rp));long long r_frac = (rp == std::string::npos) ? 0 : std::stoll(r.substr(rp+1));if(!(rp == std::string::npos)) while(d-- >= (int)(rs-rp)) { r_frac *= 10; }return {r_inte, r_frac};}long long input_deci_ll(int d) {std::pair<long long, long long> deci = input_deci(d);while(d--) { deci.first *= 10; }return deci.first + deci.second;}void solve() {long long Xs = input_deci_ll(8);long long Xb = (long long)pow(10, 8);long long Xgcd = gcd(Xs, Xb);Xs /= Xgcd;Xb /= Xgcd;cout << Xs << '/' << Xb << endl;}//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//int main() {std::ifstream in("input.txt");std::cin.rdbuf(in.rdbuf());std::cin.tie(0);ios::sync_with_stdio(false);input();solve();return 0;}