結果

問題 No.25 有限小数
ユーザー momoyuumomoyuu
提出日時 2022-08-16 14:06:13
言語 C++23(draft)
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,296 bytes
コンパイル時間 3,683 ms
コンパイル使用メモリ 245,064 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-07-26 18:39:18
合計ジャッジ時間 4,515 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define rep(i,a,b) for (int i = a; i < b; i++)
#define irep(i,a,b) for (int i = a; i > b; i--)
#define print(n) cout << n << endl
#define rup(a,b) (a+b-1)/b

using namespace std;

unsigned ll gcd(unsigned ll a,unsigned ll b){
    if (a<b){
        swap(a,b);
    }
    if (b==0) return a;
    return gcd(b,a%b);
}

int main(){
    cout << fixed << setprecision(15);
    
    unsigned ll N,M;
    cin>>N>>M;

    unsigned ll d;

    bool p = false;

    d = gcd(N,M);
    N /= d;
    M /= d;
    unsigned ll now = 1;
    int count = 0;
    while(true){
        count ++ ;
        if (count>=100) break;
        d = gcd(M,10);
        //cout<<M<<d<<endl;
        if (d==1) break;
        M /= d;
        now *= (10/d);
    }
    if (M == 1){
        string s = to_string(N);
        char now1 = '1';
        rep(i,0,s.size()){
            if (s[i]=='0'){
                continue;
            }
            now1 = s[i];
        }
        N = now * (int)(now1-'0');
        s = to_string(N);
        now1 = '1';
        rep(i,0,s.size()){
            if (s[i]=='0'){
                continue;
            }
            now1 = s[i];
        }print(now1);
    }else{
        print(-1);
    }
    //system("pause");
    return 0;
}
0