結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー BantakoBantako
提出日時 2017-08-11 18:50:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,061 bytes
コンパイル時間 1,650 ms
コンパイル使用メモリ 166,608 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 22:22:22
合計ジャッジ時間 2,529 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
6,940 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
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 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 WA -
testcase_28 AC 2 ms
6,940 KB
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1000000007;
ll pow(int n){
    ll ans = 1;
    for(int i = 0;i < n;i++){
        ans *= 10;
    }
    return ans;
}
main(){
    int N;
    ll usum = 0,dsum = 0;
    cin >> N;
    for(int i = 0;i < N;i++){
        int nflag = 1;
        ll a,b = 0;
        string s;
        cin >> s;
        if(s[0] == '-'){
            nflag = -1;
            s.erase(s.begin());
        }
        int index = s.find(".");
        if(index != -1){
            a = stoll(s.substr(0,index));
            b = stoll(s.substr(index+1,s.length()-index-1));
            b *= pow(11-s.length()+index);
        }else a = stoll(s);
        usum += a * nflag;
        dsum += b * nflag;
    }
    if(signbit(usum) == signbit(dsum)){
        usum += dsum / pow(10);
        dsum %= pow(10);
    }else{
        usum -= dsum / pow(10);
        usum += signbit(usum)*2 - 1;
        dsum %= pow(10);
        dsum = pow(10) - dsum*(1 - signbit(dsum)*2);
    }
    printf("%lld.%010lld\n",usum,dsum);
}
0