結果

問題 No.428 小数から逃げる夢
ユーザー vjudge1
提出日時 2025-08-27 21:08:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,974 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 198,048 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-27 21:08:20
合計ジャッジ時間 4,926 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 91 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
string n,d="1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991";
string trans(int x) {
    switch (x) {
        case 1: return "1";
        case 2: return "2";
        case 3: return "3";
        case 4: return "4";
        case 5: return "5";
        case 6: return "6";
        case 7: return "7";
        case 8: return "8";
        case 9: return "9";
        case 0: return 0;
        default: return "";
    }
    return "";
}
string times(string a,char _b) {
    int tmp=0;
    int b=_b-'0';
    for(int i=(int)a.size()-1;i>=0;i--) {
        int anow=a[i]-'0';
        anow=anow*b+tmp;
        tmp=anow/10;
        a[i]=anow%10+'0';
    }
    if(tmp) a=trans(tmp)+a;
    return a;
}
string add(string a,string b) {
    int i=(int)a.size()-1,j=(int)b.size()-1,tmp=0;
    string res="";
    while(i>=0||j>=0||tmp) {
        if(i>=0) tmp+=a[i--]-'0';
        if(j>=0) tmp+=b[j--]-'0';
        res.push_back(tmp%10+'0');
        tmp/=10;
    }
    reverse(res.begin(),res.end());
    return res;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    // freopen("dream.in","r",stdin); freopen("dream.out","w",stdout);
    cin>>n;
    if(n=="100") {
        cout<<"12.34567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991";
    } else if(n.size()==1) {
        string c=times(d,n[0]);
    }
    else if(n.size()==2) {
        string cc=times(d,n[0])+"0";
        string c=add(cc,times(d,n[1]));
        int ptpos=c.size()-190,zeropos=c.size()-1;
        for(int i=0;i<ptpos;i++) cout<<c[i];
        if(ptpos==0) cout<<'0';
        cout<<'.';
        while(c[zeropos]=='0') zeropos--;
        for(int i=ptpos;i<=zeropos;i++) cout<<c[i];
    }
}
0