結果
問題 | No.1447 Greedy MtSaka |
ユーザー |
![]() |
提出日時 | 2021-05-12 22:49:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 705 bytes |
コンパイル時間 | 1,915 ms |
コンパイル使用メモリ | 195,020 KB |
最終ジャッジ日時 | 2025-01-21 10:22:04 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) typedef long long ll; #define int long long double men(double x1,double y1,double x2,double y2,double x3,double y3){ double menseki=0; double a1=sqrt(pow(abs(x2-x1),2)+pow(abs(y2-y1),2)); double b1=sqrt(pow(abs(x3-x2),2)+pow(abs(y3-y2),2)); double c1=sqrt(pow(abs(x3-x1),2)+pow(abs(y3-y1),2)); double s=(a1+b1+c1)/2; menseki=sqrt(s*(s-a1)*(s-b1)*(s-c1)); return menseki; } signed main(){ int n; cin>>n; double x[n],y[n]; rep(i,n){ cin>>x[i]>>y[i]; } double ans=0; rep(i,n-2){ ans+=men(x[0],y[0],x[i+1],y[i+1],x[i+2],y[i+2]); } cout<<setprecision(10)<<ans*2<<endl; return 0; }