結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー ry0u_ydry0u_yd
提出日時 2015-09-02 00:35:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,300 bytes
コンパイル時間 772 ms
コンパイル使用メモリ 76,272 KB
実行使用メモリ 4,564 KB
最終ジャッジ日時 2023-09-25 21:51:21
合計ジャッジ時間 2,905 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
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 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string stringplus(string a,string b) {
    string ret;
    if(a.size() < b.size()) swap(a,b);

    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());

    int carry = 0;
    rep(i,b.size()) {
        int x = a[i] - '0';
        int y = b[i] - '0';
        int z = x + y + carry;

        carry = z / 10;
        ret.push_back('0' + (z%10));
    }

    REP(i,b.size(),a.size()) {
        int x = a[i] - '0';
        int z = x + carry;

        carry = z / 10;
        ret.push_back('0' + (z%10));
    }

    if(carry) ret.push_back('0' + carry);
    reverse(ret.begin(),ret.end());
    return ret;
}

double func(string s) {
    double ret = 0;
    double t = 10;
    rep(i,s.size()) {
        ret += (s[i]-'0') / t;
        t *= 10;
    }
    return ret;
}

vector<string> split(const string &str, char delim) {
    vector<string> res;
    size_t current = 0, found;
    while((found = str.find_first_of(delim, current)) != string::npos) {
        res.push_back(string(str, current, found - current));
        current = found + 1;
    }
    res.push_back(string(str, current, str.size() - current));
    return res;
}

ll stringtoi(string s) {
    ll ret;
    stringstream ss;
    ss << s;
    ss >> ret;
    return ret;
}

int main() {
    int n;
    cin >> n;

    ll a = 0, b = 0;
    rep(i,n) {
        string s;
        cin >> s;

        vector<string> ret = split(s,'.');
        ll t;
        stringstream ss;
        ss << ret[0];
        ss >> t;

        a += t;

        if(ret.size() == 2) {
            int size = ret[1].size();
            rep(i,10-size) {
                ret[1] += "0";
            }

            ll t2;
            stringstream ss2;
            ss2 << ret[1];
            ss2 >> t2;

            if(ret[0][0] == '-') {
                b -= t2;
            } else {
                b += t2;
            }
        }
    }

    cout << a + (b/10000000000) << "." << b%10000000000 << endl;

    return 0;
}
0