結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー CleyLCleyL
提出日時 2022-02-20 00:03:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,195 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 66,776 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-11 20:54:20
合計ジャッジ時間 1,711 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;
int ans[22];
int main(){
    int n;cin>>n;
    
    for(int i = 0; n > i; i++){
        string s;cin>>s;bool minus = false;
        if(s[0] == '-'){
            s = s.substr(1,s.size()-1);
            minus = true;
        }
        int dec = s.size();
        for(int j = 0; s.size() > j; j++){
            if(s[j] == '.'){
                dec = j;
                break;
            }
        }
        for(int j = 0; s.size() > j; j++){
            if(dec == j){
                continue;
            }
            if(dec < j){
                if(minus)ans[10+(j-dec)] -= s[j]-'0';
                else ans[10+(j-dec)] += s[j]-'0';
            }else{
                if(minus)ans[11+(j-dec)] -= s[j]-'0';
                else ans[11+(j-dec)] += s[j]-'0';
            }
        }
    }
    int pre = 0;
    for(int i = 20; 0 < i; i--){
        ans[i-1] += ans[i]/10;
        ans[i]%=10;
        if(ans[i] == 0 && pre == 0)pre = i+1;
        else if(ans[i] != 0){
            pre = 0;
        }
    }
    if(pre > 10)pre = 10;
    for(int i = pre; 20 >= i; i++){
        cout << ans[i];
        if(i == 10)cout << ".";
    }
    cout << endl;
        
}
0