結果

問題 No.81 すべて足すだけの簡単なお仕事です。
コンテスト
ユーザー latte0119
提出日時 2016-01-11 23:17:04
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,208 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,266 ms
コンパイル使用メモリ 179,256 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-04-08 06:44:10
合計ジャッジ時間 2,350 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N;

signed main(){
    scanf("%lld",&N);
    int x=0,y=0;
    rep(i,N){
        string s;cin>>s;
        bool m=false;
        if(s[0]=='-'){
            s=s.substr(1,s.size()-1);
            m=true;
        }
        int a=0,b=0;
        int c=find(all(s),'.')-s.begin();
        rep(i,c)a=a*10+s[i]-'0';
        reps(i,c+1,s.size())b=b*10+s[i]-'0';
        if(c!=s.size())rep(i,10-(s.size()-1-c))b*=10;
        if(m){a=-a;b=-b;}
        x+=a;y+=b;
        if(y>=10000000000ll){x++;y%=10000000000ll;}
        if(y<0){x--;y+=10000000000ll;}
    }
    if(x<0){
        x++;
        y=(10000000000ll-y)%10000000000ll;
    }
    printf("%lld.%010lld\n",x,y);
}
0