結果
問題 | No.81 すべて足すだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2018-06-22 23:08:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,621 bytes |
コンパイル時間 | 1,733 ms |
コンパイル使用メモリ | 169,028 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-22 16:42:19 |
合計ジャッジ時間 | 2,274 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#include "bits/stdc++.h" #define REP(i,n,N) for(ll i=(n); i<(N); i++) #define RREP(i,n,N) for(ll i=(N-1); i>=n; i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)<<endl #define p2(a,b) cout<<(a)<<" "<<(b)<<endl #define v2(T) vector<vector<T>> typedef long long ll; using namespace std; const ll mod= 1e10; int N; ll suma, sumb; int main(){ cin>>N; REP(i,0,N){ string a; cin>>a; int now=0; ll tmpa=0, tmpb=0; bool c=false; if(a[0]=='-'){ c=true; now++; } REP(i,now,a.size()){ if(a[i]=='.') { now++; break; } tmpa*=10; tmpa+=a[i]-'0'; now++; } int keta=0; REP(i,now,a.size()){ tmpb*=10; tmpb+=a[i]-'0'; keta++; } REP(i,0,10-keta){ tmpb*=10; } if(c){ tmpa=-tmpa; tmpb=-tmpb; } sumb+=tmpb; suma+=tmpa; } suma += sumb / mod; sumb %= mod; if (suma == 0 && sumb < 0){ cout << "-"; sumb *= -1; } if (suma < 0){ if (sumb <= 0){ sumb *= -1; } else{ suma++; sumb -= mod; sumb *= -1; if (suma == 0) cout << "-"; } } else{ if (sumb < 0){ suma--; sumb += mod; } } printf("%lld", suma); printf("."); printf("%010lld\n", sumb); return 0; }