結果

問題 No.81 すべて足すだけの簡単なお仕事です。
コンテスト
ユーザー GOTKAKO
提出日時 2026-08-28 22:14:46
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 549µs
コード長 1,295 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,210 ms
コンパイル使用メモリ 213,436 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-28 22:14:50
合計ジャッジ時間 2,970 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

template<typename T>
istream &operator>>(istream &is,vector<T> &a){
    for(auto &v : a) cin >> v;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &a){
    if(a.size() == 0) return os;
    cout << a.at(0);
    for(int i=1; i<a.size(); i++) cout << " " << a.at(i);
    cout << "\n";
    return os;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    __int128_t suma = 0;
    auto abs = [&](__int128_t x) -> __int128_t {
    	if(x < 0) return -x;
    	return x;
    };
    while(N--){
        string s; cin >> s;
        int more = 10,dec = 0;
        for(auto c : s){
            if(c == '.') dec = 1;
            else if(c != '-') more -= dec;
        }
        while(more--) s += '0';

        __int128_t now = 0;
        for(auto c : s) if(c != '.' && c != '-') now *= 10,now += c-'0';
        if(s.at(0) == '-') now = -now;
        suma += now;

    }
    string answer = "";
    bool minus = suma<0; suma = abs(suma);
    while(suma) answer += suma%10+'0',suma /= 10;
    while(answer.size() < 11) answer += '0';
    answer.insert(answer.begin()+10,'.');
    if(minus) answer += '-';
    reverse(answer.begin(),answer.end());

    cout << answer << endl;
}
0