結果

問題 No.25 有限小数
ユーザー momoyuumomoyuu
提出日時 2022-08-16 14:19:31
言語 C++23(draft)
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,671 bytes
コンパイル時間 2,718 ms
コンパイル使用メモリ 245,856 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-07-26 18:53:05
合計ジャッジ時間 4,316 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,384 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
#define end endl;

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);
}
unsigned ll calc(unsigned ll N){
            string s = to_string(N);
        char now1 = '1';
        rep(i,0,s.size()){
            if (s[i]=='0'){
                continue;
            }
            now1 = s[i];
        }
        return (unsigned ll)(now1-'0');
}
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);
        if (d==1) break;
        M /= d;
        now *= (10/d);
        now = calc(now);
        //cout<<now<<" "<<M<<end;
        }

    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');
        cout<<now<<" "<<N<<" "<<(int)(now1-'0')<<endl;
        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