結果
| 問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
tetsuzuki1115
|
| 提出日時 | 2018-09-29 03:50:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,936 bytes |
| コンパイル時間 | 994 ms |
| コンパイル使用メモリ | 100,568 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-12 07:59:48 |
| 合計ジャッジ時間 | 1,877 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 11 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;
long long MOD = 1000000007;
vector<string> split(const string &str, char sep)
{
vector<string> v; // 分割結果を格納するベクター
auto first = str.begin(); // テキストの最初を指すイテレータ
while( first != str.end() ) { // テキストが残っている間ループ
auto last = first; // 分割文字列末尾へのイテレータ
while( last != str.end() && *last != sep ) // 末尾 or セパレータ文字まで進める
++last;
v.push_back(string(first, last)); // 分割文字を出力
if( last != str.end() )
++last;
first = last; // 次の処理のためにイテレータを設定
}
return v;
}
int main() {
int N;
cin >> N;
vector<string> VS(N);
for ( int i = 0; i < N; i++ ) {
cin >> VS[i];
}
long long a,b;
a = b = 0;
for ( int i = 0; i < N; i++ ) {
vector<string> s = split(VS[i],'.');
a += stoll( s[0] );
if ( s.size() > 1 ) {
string t = s[1];
while ( t.length() < 10 ) {
t += '0';
}
long long c = ( s[0][0] == '-' ) ? -stoll(t) : stoll(t);
b += c;
}
}
a += b/10000000000;
if ( a > 0 && b < 0 ) { a--; b += 10000000000; }
if ( a < 0 && b > 0 ) { a++; b = 10000000000-b; cout << "-"; }
if ( b < 0 ) { b = -b; }
b %= 10000000000;
string x = to_string(b);
while ( x.length() < 10 ) {
x += '0';
}
cout << a << "." << x << endl;
return 0;
}
tetsuzuki1115