結果
問題 | No.1230 Hall_and_me |
ユーザー |
![]() |
提出日時 | 2020-09-24 22:41:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 988 bytes |
コンパイル時間 | 1,736 ms |
コンパイル使用メモリ | 196,264 KB |
最終ジャッジ日時 | 2025-01-14 20:09:26 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
コンパイルメッセージ
In file included from /usr/include/c++/13/istream:41, from /usr/include/c++/13/sstream:40, from /usr/include/c++/13/complex:45, from /usr/include/c++/13/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127, from main.cpp:1: In member function ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>]’, inlined from ‘int main()’ at main.cpp:35:13: /usr/include/c++/13/ostream:235:25: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized] 235 | { return _M_insert(__f); } | ~~~~~~~~~^~~~~ main.cpp: In function ‘int main()’: main.cpp:20:13: note: ‘ans’ was declared here 20 | ldouble ans; | ^~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; const double pi=3.141592653589793; typedef unsigned long long ull; typedef long double ldouble; const ll INF=1e18; #define rep(i, n) for(ll i = 0; i < (ll)(n); i++) #define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++) template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main(){ // 小数点以下第15桁まで表示させる cout.precision(15); cout << fixed; vector<int> p(3); int count = 0; ldouble ans; rep(i, 3) { cin >> p[i]; if(p[i] == 0) count++; } sort(p.begin(), p.end()); if(count == 0) { ans = (ldouble)(p[1] + p[2]) / (ldouble) (p[0] + p[1] + p[2]); } else if(count == 1) { ans = (ldouble)1; } else if(count == 2) { ans = (ldouble) 1; } cout << ans << endl; }