Submission #969754
Source Code Expand
/*#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int gcd(int a, int b) { if (!b)return a; return gcd(b, a%b); }
int main() {
int n, k; scanf("%d%d", &n, &k);
map<int, int>mp;
rep(i, n) {
int d; scanf("%d", &d);
mp[gcd(d, k)]++;
}
}*/
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b)(fabs((a)-(b))<EPS)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
struct Point {
double x, y;
Point(double x = 0, double y = 0) :x(x), y(y) {}
Point operator*(double a) { return Point(a*x, a*y); }
Point operator-(Point p) { return Point(x - p.x, y - p.y); }
Point operator+(Point p) { return Point(x + p.x, y + p.y); }
Point operator/(double a) { return Point(x / a, y / a); }
double norm() { return x*x + y*y; }
};
typedef Point Vector;
struct Segment {
Point p1, p2;
};
double dot(Point a, Point b) {
return a.x*b.x + a.y*b.y;
}
Point project(Segment s, Point p) {
Point base = s.p2 - s.p1;
double r = dot(p - s.p1, base) / base.norm();
return s.p1 + base*r;
}
double norm(Vector a) {
return a.x*a.x + a.y*a.y;
}
double abs(Vector a) {
return sqrt(norm(a));
}
typedef Segment Line;
class Circle {
public:
Point c;
double r;
Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};
pair<Point, Point>getC(Circle c, Line l) {
Vector pr = project(l, c.c);
Vector e = (l.p2 - l.p1) / abs(l.p2 - l.p1);
double base = sqrt(c.r*c.r - norm(pr - c.c));
return make_pair(pr + e*base, pr - e*base);
}
int main() {
double r, n, m; cin >> r >> n >> m;
Circle c({ 0., r }, r);
double ans = 0;
for (double j = 1; j <= n + m - 1; j++) {
double i = ((2. * r) / n)*j, k = ((2.*r) / n)*(j - m);
if (j - m <= 0) {
Line l = { { -(1e7), i },{ 1e7, i } };
auto p1 = getC(c, { { -(1e7),i } ,{ 1e7,i } });
ans += sqrt(abs(p1.first.x - p1.second.x)*abs(p1.first.x - p1.second.x));
}
else if (j >= n - 1) {
auto p2 = getC(c, { { -(1e7),k },{ 1e7,k } });
ans += sqrt(abs(p2.first.x - p2.second.x)*abs(p2.first.x - p2.second.x));
}
else {
auto p1 = getC(c, { { -(1e7),i } ,{ 1e7,i } }), p2 = getC(c, { { -(1e7),k },{ 1e7,k } });
ans += max(sqrt(abs(p1.first.x - p1.second.x)*abs(p1.first.x - p1.second.x)),
sqrt(abs(p2.first.x - p2.second.x)*abs(p2.first.x - p2.second.x)));
}
}
printf("%.15lf\n", ans);
}
Submission Info
Submission Time |
|
Task |
B - ステップカット |
User |
autumn_eel |
Language |
C++14 (GCC 5.4.1) |
Score |
200 |
Code Size |
2384 Byte |
Status |
AC |
Exec Time |
10 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
200 / 200 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All |
00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 20_hand_01.txt, 20_hand_02.txt, 20_hand_03.txt, 20_hand_04.txt, 20_hand_05.txt |
Case Name |
Status |
Exec Time |
Memory |
00_example_01.txt |
AC |
3 ms |
256 KB |
00_example_02.txt |
AC |
3 ms |
256 KB |
00_example_03.txt |
AC |
9 ms |
256 KB |
10_rand_01.txt |
AC |
3 ms |
256 KB |
10_rand_02.txt |
AC |
3 ms |
256 KB |
10_rand_03.txt |
AC |
5 ms |
256 KB |
10_rand_04.txt |
AC |
3 ms |
256 KB |
10_rand_05.txt |
AC |
3 ms |
256 KB |
10_rand_06.txt |
AC |
3 ms |
256 KB |
10_rand_07.txt |
AC |
4 ms |
256 KB |
10_rand_08.txt |
AC |
3 ms |
256 KB |
20_hand_01.txt |
AC |
9 ms |
256 KB |
20_hand_02.txt |
AC |
10 ms |
256 KB |
20_hand_03.txt |
AC |
9 ms |
256 KB |
20_hand_04.txt |
AC |
3 ms |
256 KB |
20_hand_05.txt |
AC |
3 ms |
256 KB |