結果

問題 No.428 小数から逃げる夢
ユーザー vjudge1
提出日時 2025-08-24 11:31:41
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,042 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 161,748 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-24 11:31:46
合計ジャッジ時間 4,678 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

# include <bits/stdc++.h>
# define FILE(x) freopen(x ".in", "r", stdin); freopen(x ".out", "w", stdout);
using namespace std;
string s = " 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991"; 
int n;
int a[200], b[200], c[200];
int zero = 1;
void solve()
{
    cin >> n;
    for (int i = 1; i <= 190; i ++)
    {
        a[i] = s[191 - i] - '0';
    }
    for (int i = 1; i <= 190; i ++)
    {
        c[i] = b[i] + a[i] * n;
        b[i + 1] = c[i] / 10;
        c[i] %= 10;
    }
    int p = 191;
    while (b[p] > 0)
    {
        c[p] = b[p] % 10;
        p ++;
        b[p] = b[p - 1] / 10;
    }
    if (p == 191) cout << 0;
    while (!c[zero]) zero ++;
    for (int i = p - 1; i >= zero; i --)
    {
        if (i == 190) cout << '.';
        cout << c[i];
    }
}
int main()
{
    ios :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int T = 1;
    while (T --) solve();
    return 0;
}
0