結果
| 問題 | 
                            No.8072 Sum of sqrt(x)
                             | 
                    
| ユーザー | 
                             vwxyz
                         | 
                    
| 提出日時 | 2021-10-26 01:58:18 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 863 bytes | 
| コンパイル時間 | 5,957 ms | 
| コンパイル使用メモリ | 368,440 KB | 
| 実行使用メモリ | 13,764 KB | 
| 最終ジャッジ日時 | 2024-10-04 03:18:10 | 
| 合計ジャッジ時間 | 21,803 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 3 | 
| other | WA * 4 TLE * 1 OLE * 3 -- * 19 | 
ソースコード
#include <iostream>
#include <ios>
#include <iomanip>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
typedef cpp_int Bint;
Bint sqrt_floor(Bint x)
{
    Bint ceil = x, floor = 1;
    while (ceil > floor + 1) {
        auto m = (ceil+floor)/2;
        if (m*m <= x)
            floor = m;
        else
            ceil = m;
    }
    return floor;
}
int main()
{
    const int prec = 20;
    Bint unit = pow(Bint(10),prec);
    cout<<unit<<endl;
    int N;
    cin >> N;
    Bint ans = 0;
    for (auto i=0; i<N; ++i) {
        Bint x;
        cin >> x;
        auto p = sqrt_floor(x);
        cout << ans / unit 
             << "."
             << setfill('0') << right << setw(prec - 3)
             << (ans % unit)/1000
             << std::setfill(' ')
             << endl;
    }
    return 0;
}
            
            
            
        
            
vwxyz