結果
| 問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
koyumeishi
|
| 提出日時 | 2014-11-28 00:56:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,368 bytes |
| コンパイル時間 | 851 ms |
| コンパイル使用メモリ | 82,288 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-03 09:55:43 |
| 合計ジャッジ時間 | 1,904 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 14 |
ソースコード
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;
void func(long long &a, long long &b, string s){
}
int main(){
int n;
cin >> n;
long long a = 0;
long long b = 0;
for(int i=0; i<n; i++){
string s;
cin >> s;
long long sgn = 1;
if(s[0] == '-'){
s = s.substr(1);
sgn = -1;
}
//cerr << s << endl;
auto pos = s.find('.');
{
string sub = s.substr(0, pos);
//cerr << sub << endl;
stringstream ss;
ss << sub;
long long x;
ss >> x;
a += sgn * x;
}
if(pos != string::npos){
string sub = s.substr(pos+1);
for(int i=0; i<10; i++){
sub += '0';
}
//cerr << sub.substr(0,10) << endl;
stringstream ss;
ss << sub.substr(0,10);
long long x;
ss >> x;
b += sgn * x;
}
a += b/10000000000LL;
b %= 10000000000LL;
}
if(a>0 && b<0){
a--;
b += 10000000000LL;
}else if(a<0 && b>0){
a++;
b -= 10000000000LL;
}
long long sgn = a<0 || b<0 ? -1:1;
b = abs(b);
stringstream ss;
ss << b;
string bs;
ss >> bs;
for(int i=0; i<10; i++){
bs = '0' + bs;
}
cout << (sgn<0?"-":"") << a << '.' << bs.substr(bs.size()-10,10) << endl;
return 0;
}
koyumeishi