結果
問題 | No.81 すべて足すだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2020-05-15 15:29:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,159 bytes |
コンパイル時間 | 1,687 ms |
コンパイル使用メモリ | 173,704 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 12:54:06 |
合計ジャッジ時間 | 2,554 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 WA * 1 |
ソースコード
#include <bits/stdc++.h> using namespace std; signed main(){ int N; cin >> N; vector< __int128 > A( N ); for( int i = 0; i < N; ++i ){ string S; cin >> S; int neg = S[ 0 ] == '-'; if( neg ) S = S.substr( 1 ); for( int j = 0; j < S.size(); ++j ){ if( S[ j ] == '.' ){ S = S.substr( j ); break; } A[ i ] = A[ i ] * 10 + S[ j ] - '0'; } if( S[ 0 ] == '.' ) S = S.substr( 1 ); else S = ""; for( int j = 0; j < S.size(); ++j ) A[ i ] = A[ i ] * 10 + S[ j ] - '0'; for( int j = 0; j < 10 - S.size(); ++j ) A[ i ] = A[ i ] * 10; if( neg ) A[ i ] *= -1; } __int128 sum = 0; for( int i = 0; i < N; ++i ) sum += A[ i ]; int neg = 0; if( sum < 0 ) sum *= -1, neg = 1; string ans; while( sum ) ans += ( char ) ( '0' + sum % 10 ), sum /= 10; reverse( ans.begin(), ans.end() ); if( ans.empty() ){ cout << "0.0000000000" << endl; exit( 0 ); } if( ans.size() <= 10 ) ans = "0." + ans; else ans = ans.substr( 0, ans.size() - 10 ) + "." + ans.substr( ans.size() - 10 ); if( neg ) cout << "-"; cout << ans << endl; return 0; }