結果

問題 No.1842 Decimal Point
ユーザー milanis48663220milanis48663220
提出日時 2022-02-18 23:14:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,189 bytes
コンパイル時間 1,028 ms
コンパイル使用メモリ 115,800 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 20:04:47
合計ジャッジ時間 2,533 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}


ll mod_pow(ll a, ll n, ll mod) {
    ll ans = 1;
    while (n > 0) {
        if (n&1) ans = (ans*a)%mod;
        a = (a*a)% mod;
        n >>= 1;
    }
    return ans;
}

void solve(){
    ll a, b, c; cin >> a >> b >> c;
    while(b%2 == 0){
        if(a%2 == 0){
            a /= 2;
            b /= 2;
        }else{
            a *= 10;
            c--;
        }
    }
    while(b%5 == 0){
        if(a%5 == 0){
            a /= 5;
            b /= 5;
        }else{
            a *= 10;
            c--;
        }
    }
    // cout << a << ' ' << b << ' ' << c << endl;

    if(c <= 0){
        ll x = a/b;
        while(c--) x /= 10;
        cout << x%10 << endl;
        return;
    }
    ll x = (a*mod_pow(10, c, b))%b;
    int r = (10-x%10)%10;
    for(int i = 0; i < 10; i++){
        if((b*i)%10 == r){
            cout << i << endl;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int t; cin >> t;
    while(t--) solve();
}
0