結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-23 17:23:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 619 bytes
コンパイル時間 1,781 ms
コンパイル使用メモリ 193,072 KB
最終ジャッジ日時 2025-01-07 14:42:42
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin>>n;
    ll a=0,b=0;
    while (n--) {
        string s;cin>>s;
        int sign=1;
        if (s[0]=='-') {
            sign=-1;
            s=s.substr(1);
        }
        ll c=0,d=0;
        sscanf(s.c_str(),"%lld.%lld",&c,&d);
        while (d!=0&&d<1e9) {
            d*=10;
        }
        a+=c*sign;
        b+=d*sign;
        if (b>=1e10) {
            a++;
            b-=1e10;
        } else if (b<0) {
            a--;
            b+=1e10;
        }
    }
    printf("%lld.%010lld\n",a,b);
    return 0;
}
0