結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー なおなお
提出日時 2014-11-07 05:00:25
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,011 bytes
コンパイル時間 1,728 ms
コンパイル使用メモリ 147,720 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-21 12:56:12
合計ジャッジ時間 3,178 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

// 想定解
#include <bits/stdc++.h>
using namespace std;
void rc(int v,int mn,int mx){if(v<mn||mx<v){cerr<<"error"<<endl;exit(1);}}
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))

const int MAXN = 100;
const long long MAXF = 10000000000LL;

void f(const string &s, long long &ip, long long &fp){
    stringstream ss(s);
    string vf; char delim;
    ss >> ip >> delim >> vf;
    while(vf.size()<10) vf += "0";
    stringstream ssf(vf);
    ssf >> fp;
    if(s[0] == '-') fp=-fp;
    //cerr << ip << "." << fp << endl;
}

int main(){
    int N;
    cin >> N; rc(N, 0, MAXN);
    long long inte=0,frac=0;
    REP(i, N){
        string s; cin >> s;
        long long vi=0,vf=0;
        f(s, vi, vf);
        inte += vi; frac += vf;
    }
    while(frac < 0){inte--; frac += MAXF; }
    while(frac >= MAXF){inte++; frac -= MAXF; }

    if(inte < 0 && frac > 0){
        inte++; frac = MAXF - frac;
    }

    printf("%lld.%010lld\n", inte, frac);
    return 0;
}
0