题目连接:https://icpcarchive.ecs.baylor.edu/external/61/6142.pdf
Mathematicians have often solved problems by just doing some simulation or experiments. For example, the value of pi (p) can be approximately determined by randomly plotting points in a square that inscribes a circle. Because if the square is a 250x250 square, then its area is 62500 and the area of the inscribed circle is pi*1252=15625pi. As the points are plotted randomly, so it can be assumed that number of points inside the circle and total number points plotted in the square is proportional to their respective area. So, in this way, the value of pi can approximately be determined by counting how many points are inside the circle (Figure 1). The value of pi can even be determined using a more sophisticated experiment like the Buffon’s needle experiment (Figure 2).
Sample Input | Sample Output |
4 71 234.600 33.576 20.375 84.908 7 7 11.586 114.435 248.411 108.640 287.629 150.224 340.481 0 0
| Case 1: 2 Case 2: 12 |
周末做了一次BUAA 的练习,发现这题有点意思。
题目就是求一个元上的点能组成多少个锐角三角行;
给出来各个点的度数,而本题发现与圆的半径没关系,多余的条件,本题主要考虑到锐角三角行,那么我们不妨考虑一下钝角三角形的个数和直角三角形,然后用总数减去钝角三角形和直角,而钝角和直角三角行有个特点,就是每个三角形在同一个半圆内;那么这样就好考虑了,而注意大于360度的情况,而我的处理就是开一个2*n的数组,然后求解就比价容易,而本题用来二分查找和排序等问题:
代码:
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<sstream>
#include<cassert>
using namespace std;
#define LL long long
#define eps 1e-6
double a[50000];
int main() {
int n,r;
int t=1;
while(cin>>n>>r) {
if(n==0&&r==0) break;
for(int i=1; i<=n; i++) {
scanf("%lf",&a[i]);
}
LL all=(LL)n*(n-1)*(n-2)/6;
sort(a+1,a+1+n);
for(int i=1; i<=n; i++) {
a[i+n]=a[i]+360.00;
}
for(int i=1; i<=n; i++) {
int l,r,mi;
l=i;
r=2*n-1;
while(l<r) {
mi=(l+r+1)/2;
if(a[mi]-a[i]<=180.00+eps) {
l=mi;
} else {
r=mi-1;
}
}
l=l-i;
LL ans=(LL)l*(l-1)/2;
all-=ans;
}
cout<<"Case "<<t++<<": ";
cout<<all<<endl;
}
return 0;
}
/*
4 71
234.600
33.576
20.375
84.908
7 7
11.586
114.435
248.411
108.640
287.629
150.224
340.481
*/