結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー face4face4
提出日時 2018-08-16 20:41:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,045 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 68,624 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 02:34:10
合計ジャッジ時間 2,257 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
using namespace std;
typedef long long ll;

int main(){
    int n;
    ll accum = 0;

    cin >> n;

    string a;
    for(int i = 0; i < n; i++){
        cin >> a;
        int dotpos;
        for(dotpos = 0; dotpos < a.length(); dotpos++)  if(a[dotpos] == '.')    break;
        ll val;
        if(dotpos == a.length()){
            val = stoll(a) * 10000000000;
        }else{
            int residual = 10;
            while(dotpos != a.length()-1){
                swap(a[dotpos], a[dotpos+1]);
                residual--;
                dotpos++;
            }
            val = stoll(a.substr(0, a.length()-1));
            while(residual-- > 0)   val *= 10;
        }
        accum += val;
    }

    bool minus = accum < 0;

    accum = abs(accum);

    string decimal = "";
    for(int i = 0; i < 10; i++){
        int digit = accum % 10;
        decimal = (char)('0' + digit) + decimal;
        accum /= 10;
    }

    cout << (minus ? "-" : "") << accum << "." << decimal << endl;

    return 0;
}
0