QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#71531#3233. Everything Has Changedzhangboju#AC ✓0ms4156kbC++17755b2023-01-11 08:43:182023-01-11 08:43:20

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-11 08:43:20]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:4156kb
  • [2023-01-11 08:43:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x)
{
	x=0;short f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x*=f;return;
}
const double PI=acos(-1);
int n,R;
int main()
{
	int T;read(T);
	while(T--)
	{
		read(n),read(R);
		double ans=2*PI*R;
		while(n--)
		{
			int x,y,r;read(x),read(y),read(r);
			double len=hypot(x,y);
			if(abs(R-r)<=len&&len<=R+r)
			{
				double theta=double(r*r+x*x+y*y-R*R)/(2*r*len);
				theta=acos(theta);
				ans+=2*theta*r;
				theta=double(R*R+x*x+y*y-r*r)/(2*R*len);
				theta=acos(theta);
				ans-=2*theta*R;
			}
		}
		printf("%.10lf\n",ans);
	} 
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 4156kb

input:

1000
55 551
85 920 149
443 -899 185
20 597 32
900 59 191
-545 424 7
-878 -69 63
-143 -844 282
-390 961 275
839 -549 227
-582 -147 27
-439 550 99
-70 706 69
224 -937 20
-968 609 125
141 700 5
527 -290 15
-171 640 4
-613 -301 65
679 -175 14
314 -486 3
-287 528 17
-553 -108 3
-202 521 2
573 -301 24
905...

output:

5793.0285377859
730.8956045996
106.8141502221
5607.3394168535
4817.0445137482
7132.2657518376
97.3237412174
2579.5598791612
2831.6319844540
4828.8504561752
2690.1493897758
8643.5476551756
5747.5882245566
2696.4366405352
3448.4811645950
11698.9346816060
7915.2492474825
3240.6841808748
8416.1669763373...

result:

ok 1000 numbers