結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー satanicsatanic
提出日時 2016-03-31 19:32:05
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,034 bytes
コンパイル時間 574 ms
コンパイル使用メモリ 68,044 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 06:51:56
合計ジャッジ時間 2,591 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 RE -
testcase_04 AC 1 ms
6,944 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 1 ms
6,944 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 WA -
testcase_28 AC 2 ms
6,940 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

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