結果

問題 No.105 arcの六角ボルト
ユーザー ty70
提出日時 2015-06-02 11:33:34
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 34 ms / 5,000 ms
コード長 2,234 bytes
コンパイル時間 920 ms
コンパイル使用メモリ 102,888 KB
実行使用メモリ 6,812 KB
最終ジャッジ日時 2024-07-06 13:34:59
合計ジャッジ時間 1,342 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cstdlib> // require abs exit atof atoi
#include <cstdio> // require scanf printf
#include <functional>
#include <numeric> // require accumulate
#include <cmath> // require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip> // require setw
#include <sstream> // require stringstream
#include <cstring> // require memset
#include <cctype> // require tolower, toupper
#include <fstream> // require freopen
#include <ctime> // require srand
#include <complex>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define EPS 1e-4
#define PI 3.141592653589793238462643383279
// 2
#define EQ(a,b) (abs((a)-(b)) < EPS)
using namespace std;
typedef complex<double> P;
//
bool cmp (P a, P b )
{
double arga = arg (a );
double argb = arg (b );
if (!EQ (arga, argb ) ){
return arga < argb;
} // end if
return abs (a ) > abs (b );
}
const double base[6] = { -180, -120, -60, 0, 60, 120 };
int main()
{
ios_base::sync_with_stdio(0);
int T; cin >> T;
while (T-- ){
vector<P> p(6 );
rep (i, 6 ){
double x, y; cin >> x >> y;
p[i] = P(x, y );
} // end rep
sort (ALL (p ), cmp );
set<double> ans; ans.clear();
// cerr << "diff:" << endl;
rep (i, 6 ){
double curr = 180.*arg (p[i] )/PI;
if (abs (curr + 180. ) < EPS ) curr = -180.;
double diff = curr - base[i];
// fprintf(stderr, "%.8lf ", diff );
if (abs(diff ) < EPS || abs (diff - 60. ) < EPS ) diff = 0.;
ans.insert (diff );
// fprintf(stderr, "%.8lf\n", diff );
} // end rep
double res = 0.;
// cerr << "ans_size: " << ans.size() << ' ';
if (ans.size() == 1 ){
res = *ans.begin();
}else{
double sum = 0.;
set<double>::iterator it = ans.begin();
for (; it != ans.end(); it++ ){
sum += (*it);
// cerr << (*it) << ' ';
} // end for
// cerr << endl;
res = sum/(double)ans.size();
} // end if
printf ("%.8lf\n", res );
} // end while
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0