-
-
Save saadismail/7a363320c923a9e0a71977aa21fc097d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <climits> | |
| #include <cmath> | |
| using namespace std; | |
| int n; | |
| double x, y; | |
| double dist; | |
| double calcdis (double x1, double y1) { | |
| return sqrt(pow(x-x1, 2) + pow(y-y1, 2)); | |
| } | |
| void solve(int currSec, double cx, double cy, int angle) { | |
| if (currSec > n) return; | |
| dist = calcdis(cx + (10 * cos(M_PI * angle / 180.0)), cy + (10 * sin(M_PI * angle / 180.0))); | |
| solve(currSec+1, cx + (10 * cos(M_PI * angle / 180.0)), cy + (10 * sin(M_PI * angle / 180.0)), angle); | |
| solve(currSec+1, cx, cy, (angle+45) % 360); | |
| } | |
| int main(void) { | |
| int t; cin >> t; | |
| while (t--) { | |
| cout << dist << endl; | |
| cin >> n >> x >> y; | |
| dist = calcdis(0, 0); | |
| solve(1, 0.0, 0.0, 0); | |
| solve(1, 0.0, 0.0, 45); | |
| cout << dist << endl; | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment