結果
問題 |
No.428 小数から逃げる夢
|
ユーザー |
|
提出日時 | 2020-07-15 14:58:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 1,000 ms |
コード長 | 1,348 bytes |
コンパイル時間 | 1,044 ms |
コンパイル使用メモリ | 113,496 KB |
最終ジャッジ日時 | 2025-01-11 21:09:00 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <map> #include <queue> #include <cstdio> #include <ctime> #include <assert.h> #include <chrono> #include <random> #include <numeric> #include <set> using namespace std; typedef long long int ll; using ull = unsigned long long; string add(string a,string b){ int maxlen=max(a.size(),b.size())+1; vector<int> ret(maxlen,0); string ans=""; reverse(a.begin(),a.end()); reverse(b.begin(),b.end()); for(int i=0;i<a.size();i++){ ret[i]+=(a[i]-'0'); } for(int i=0;i<b.size();i++){ ret[i]+=(b[i]-'0'); } for(int i=0;i<maxlen-1;i++){ ans+=(ret[i]%10)+'0'; ret[i+1]+=ret[i]/10; } if(ret[maxlen-1]){ ans+=ret[maxlen-1]+'0'; } reverse(ans.begin(),ans.end()); return ans; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; string s="1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991"; string res="0"; while(n--){ res=add(res,s); } s=""; for(int i=0;i<res.size();i++){ if(i+190==res.size())s+="."; s+=res[i]; } if(s[0]=='.')s="0"+s; cout << s << endl; }