結果

問題 No.858 わり算
ユーザー peroonperoon
提出日時 2019-08-13 14:38:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,597 bytes
コンパイル時間 11,564 ms
コンパイル使用メモリ 419,624 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 17:06:02
合計ジャッジ時間 10,527 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:63:28: warning: 'p' may be used uninitialized [-Wmaybe-uninitialized]
   63 |     string sub = s.substr(p+1, 50);
      |                           ~^~
main.cpp:53:8: note: 'p' was declared here
   53 |     ll p;
      |        ^

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) FOR(i, 0, a)
#define ALL(v) (v).begin(), (v).end()

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <iostream>

// あえて多倍長整数を使ってみる

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    namespace mp = boost::multiprecision;
    // 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
    using Real = mp::number<mp::cpp_dec_float<1024>>;

    // input
    Real A, B; cin >>A>>B;
    ll AA = (ll)A;
    ll BB = (ll)B;
    
    stringstream ss;
    ss << setprecision(55) << A/B;
    string s;
    if(AA%BB==0){
        s = ss.str() + ".000000000000000000000000000000000000000000000000000000000000000000000000000";    
    }else{
        s = ss.str() + "0000000000000000000000000000000000000000000000000000000000000000000000000000";
    }
    
    ll L = s.size();
    ll p;
    rep(i, L){
        char c = s[i];
        cout << c;
        if(c=='.') {
            p = i;
            break;
        }
    }

    string sub = s.substr(p+1, 50);
    cout << sub;
    
    
    return 0;
}
0