結果
| 問題 | No.1464 Number Conversion | 
| コンテスト | |
| ユーザー |  hiro71687k | 
| 提出日時 | 2023-04-11 12:13:28 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 942 bytes | 
| コンパイル時間 | 3,284 ms | 
| コンパイル使用メモリ | 250,868 KB | 
| 最終ジャッジ日時 | 2025-02-12 05:00:15 | 
| ジャッジサーバーID (参考情報) | judge2 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 WA * 19 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=144499999999994;
ll mod=998244353;
ll gcd(ll a, ll b) {
	a = abs(a); b = abs(b);
	if (a < b)swap(a, b);
	while (b) {
	    ll r=a%b;
        a=b;
	    b=r;
	}
	return a;
}
int main(){
    string s;
    cin >> s;
    bool ok=true;
    for (ll i = 0; i < s.size(); i++)
    {
        if (s[i]=='.')
        {
            ok=false;
            break;
        }
    }
    if (ok)
    {
        cout << s << "/1" << endl;
        return 0;
    }
    ll x=s.size();
    ll now=1;
    for (ll i = 0; i < x-2; i++)
    {
        now*=10;
    }
    string t;
    for (ll i = 0; i < s.size(); i++)
    {
        if (s[i]!='.')
        {
            t.push_back(s[i]);
        }
    }
    ll y=stoll(t);
    ll z=gcd(y,now);
    y/=z;
    now/=z;
    cout << y << '/' << now << endl;
}
            
            
            
        