結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー goodbatongoodbaton
提出日時 2014-11-28 00:48:25
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,159 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 72,324 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-01 22:33:41
合計ジャッジ時間 1,872 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;




int main(){
    char in[25];
    int sei[13]={0},syo[13]={0},n,p=0,memo[12],me=0;
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%s",in);
        
        if(in[0]!='-'){
            me=0;
            for(int j=0;in[j]!='\0' && in[j]!='.';j++){
                memo[j]=in[j]-'0';
                me++;
            }
            
            for(int j=0;j<me;j++){
                sei[me-j-1]+=memo[j];
            }
            
            if(in[me]=='.'){
                for(int j=1;in[j+me]!='\0';j++){
                    syo[j-1]+=in[j+me]-'0';
                }
            }
        }else{
            me=1;
            for(int j=1;in[j]!='\0' && in[j]!='.';j++){
                memo[j]=in[j]-'0';
                me++;
            }
            
            for(int j=0;j<me;j++){
                sei[me-j-1]-=memo[j];
            }
            
            if(in[me]=='.'){
                for(int j=1;in[j+me]!='\0';j++){
                    syo[j-1]-=in[me+j]-'0';
                }
            }
        }
    }
    
    for(int k=0;k<13;k++){
        if(12-k>0 && syo[12-k]>=10){
            syo[11-k]+=syo[12-k]/10;
            syo[12-k]%=10;
        }
        if(12-k>0 && syo[12-k]<0){
            syo[11-k]+=(syo[12-k]+1)/10-1;
            syo[12-k]=syo[12-k]%10+10;
        }
    }
    
    if(syo[0]>=0){
        sei[0]+=syo[0]/10;
        syo[0]%=10;
    }else{
        sei[0]+=(syo[0]+1)/10-1;
        syo[0]=syo[0]%10+10;
    }

    for(int k=0;k<13;k++){
        if(sei[k]>=10){
            sei[k+1]+=sei[k]/10;
            sei[k]%=10;
        }
    }
    
    for(int i=0;i<13;i++){
        if(sei[12-i]>0 || p==1){
            printf("%d",sei[12-i]);
            p=1;
        }
    }
    printf(".");
    for(int i=0;i<10;i++){
        printf("%d",syo[i]);
    }
    
    printf("\n");
    return 0;
}
0