結果
| 問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2014-11-28 00:09:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,952 bytes |
| コンパイル時間 | 1,108 ms |
| コンパイル使用メモリ | 76,488 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-03 09:44:41 |
| 合計ジャッジ時間 | 2,043 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:24:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | scanf("%s",in);
| ~~~~~^~~~~~~~~
ソースコード
#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[k]/10;
syo[12-k]%=10;
}
}
sei[0]+=syo[0]/10;
syo[0]%=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;
}
goodbaton