Submission #3594603
Source Code Expand
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
using ll = long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };
template<class T> void corner(bool flg, T hoge) {
if (flg) {
cout << hoge << endl;
exit(0);
}
else return;
}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
o << "{" << obj.first << ", " << obj.second << "}"; return o;
}
template <template <class tmp> class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
void print(void) {
cout << endl;
}
template <class Head> void print(Head&& head) {
cout << head;
print();
}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
cout << head << " ";
print(forward<Tail>(tail)...);
}
void YN(bool flg) {
cout << ((flg) ? "YES" : "NO") << endl;
}
void Yn(bool flg) {
cout << ((flg) ? "Yes" : "No") << endl;
}
void yn(bool flg) {
cout << ((flg) ? "yes" : "no") << endl;
}
int main() {
double R; cin >> R;
int N, M; cin >> N >> M;
V<double> L(N + 1, 0.);
for (int i=0; i < N; ++i) {
double x = 2 * R*i / N;
x = abs(x - R);
L[i] = 2*sqrt(R*R-x*x);
}
double ans = 0.;
FOR(i,1,N+M){
ans += max(L[(i<=N)?i:0], L[(0<=i-M)?(i - M):0]);
}
printf("%.10f", ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
B - ステップカット |
User |
ningenMe |
Language |
C++14 (GCC 5.4.1) |
Score |
200 |
Code Size |
2718 Byte |
Status |
AC |
Exec Time |
3 ms |
Memory |
1024 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 |
1 ms |
256 KB |
00_example_02.txt |
AC |
1 ms |
256 KB |
00_example_03.txt |
AC |
3 ms |
1024 KB |
10_rand_01.txt |
AC |
1 ms |
256 KB |
10_rand_02.txt |
AC |
1 ms |
256 KB |
10_rand_03.txt |
AC |
2 ms |
640 KB |
10_rand_04.txt |
AC |
1 ms |
256 KB |
10_rand_05.txt |
AC |
1 ms |
256 KB |
10_rand_06.txt |
AC |
1 ms |
256 KB |
10_rand_07.txt |
AC |
2 ms |
384 KB |
10_rand_08.txt |
AC |
1 ms |
256 KB |
20_hand_01.txt |
AC |
3 ms |
1024 KB |
20_hand_02.txt |
AC |
3 ms |
1024 KB |
20_hand_03.txt |
AC |
3 ms |
1024 KB |
20_hand_04.txt |
AC |
1 ms |
256 KB |
20_hand_05.txt |
AC |
1 ms |
256 KB |