結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー satanic
提出日時 2016-03-31 19:32:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 1,034 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 67,604 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-02 08:32:34
合計ジャッジ時間 2,996 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 WA * 13 RE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    int n;
    std::string input, inputInt, inputDec;
    long long int ansInt = 0, ansDec = 0;
    std::cin >> n;
    for(int i=0; i<n; ++i){
        std::cin >> input;
        if(input.find('.') == std::string::npos){
            ansInt += std::stoi(input);
        }else{
            std::istringstream ist(input);
            std::getline(ist, inputInt, '.');
            ansInt += std::stoi(inputInt);
            std::getline(ist, inputDec);
            while(inputDec.size()<10){
                inputDec += '0';
            }
            ansDec += static_cast<long long int>(std::stod(inputDec)) * ((input[0]=='-') ? -1 : 1);
        }
    }
    ansInt += ansDec/10000000000;
    ansDec %= 10000000000;
    inputDec = std::to_string(ansDec);
    while(inputDec.size()<10){
        inputDec += '0';
    }
    std::cout << ansInt << '.' << inputDec << "\n";

    return 0;
}
0