結果

問題 No.1464 Number Conversion
ユーザー arashinarashin
提出日時 2021-04-02 23:53:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 963 bytes
コンパイル時間 1,455 ms
コンパイル使用メモリ 166,964 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 14:30:03
合計ジャッジ時間 2,651 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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());
    bool f = true;
    while(f){
        f = false;
        if (tsi % 2 == 0){
            tsi /= 2;
            b /= 2;
            f = true;
        }
        if (tsi % 5 == 0){
            tsi /= 5;
            b /= 5;
            f = true;
        }
    }

	cout << tsi << "/"<< b << endl;
	return 0;
}
0