Submission #5202
Source Code Expand
#include <iostream> #include <cmath> using namespace std; int N, start, goal; double x, y; double nextX(int step){ int dy = N - y; int dx = x - goal; if (dy == 0) return -1; return (double)(dx * step) / (double)dy; } main(){ cin >> N >> start >> goal; double d = 0; x = start; y = 0; //cout << "x: " << x << ", y: " << y << endl; for (int i = 0; i <= N; i++){ int c1, c2; cin >> c1 >> c2; double next = x + nextX(i - y); //cout << "next:" << c1 << " / " << next << " / " << c2 << endl; if (c1 <= next && next <= c2){ }else{ //int nx = min(abs(x-c1), abs(x-c2)); int nx = abs(x-c1) < abs(x-c2) ? c1 : c2; d += sqrt((double)((nx - x) * (nx - x) + (i - y) * (i - y))); x = nx; y = i; //cout << "#" << i << ",x: " << x << ", y: " << y << ", d: " << d << endl; } } d += sqrt((double)((goal - x) * (goal - x) + (N - y) * (N - y))); printf("%.14g\n", d); }
Submission Info
Submission Time | |
---|---|
Task | D - レースゲーム |
User | xrekkusu |
Language | C++ (GCC 4.4.7) |
Score | 0 |
Code Size | 999 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:46: error: ‘printf’ was not declared in this scope