結果
問題 |
No.428 小数から逃げる夢
|
ユーザー |
![]() |
提出日時 | 2023-01-09 00:15:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,022 bytes |
コンパイル時間 | 940 ms |
コンパイル使用メモリ | 74,676 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-16 04:09:10 |
合計ジャッジ時間 | 3,707 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; int main(){ string d0 = "1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991"; int n; cin >> n; vector<int> d(210, 0), a(210, 0); reverse(d0.begin(), d0.end()); for(int i = 0; i < d0.size(); i++) d[i] = d0[i]-'0'; for(int i = 0; i < d0.size(); i++){ int x = d[i]*n; for(int j = 0; j < 5; x /= 10, j++){ a[i+j] += x%10; if(a[i+j] >= 10){ a[i+j] %= 10; a[i+j+1]++; } } } string ans = ""; for(int i = 190; i < 210; i++) ans += to_string(a[i]); while(ans.size() > 1 && ans.back() == '0') ans.pop_back(); reverse(ans.begin(), ans.end()); ans += '.'; for(int i = 189; i >= 0; i--) ans += to_string(a[i]); cout << ans << endl; return 0; }