Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef complex<double> cd;
- typedef vector<vector<cd>> matrix;
- matrix operator*(matrix& a, matrix& b) {
- matrix ans(2, vector<cd>(2, 0));
- for (int i = 0;i < 2;i++) {
- for (int j = 0;j < 2;j++) {
- for (int k = 0;k < 2;k++) {
- ans[i][j] += a[i][j + k] * b[j + k][i];
- }
- }
- }
- return ans;
- }
- matrix xp(matrix& b, int e) {
- if (e == 1) return b;
- matrix c = xp(b, e / 2);
- c = c * c;
- if (e & 1) c = c * b;
- return c;
- }
- int main() {
- int t;
- cin >> t;
- int alf, n;
- double l;
- matrix base = {{0, 1}, {1, 1}};
- while (t--) {
- cin >> alf >> l >> n;
- double alfa = acos(-1) * alf / 180.0;
- base[0][0] = cd(cos(alfa), sin(alfa));
- auto exp = xp(base, n);
- cd pos = (base[0][1] + base[1][1]) * l;
- printf("%.2f %.2f\n", pos.real(), pos.imag());
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement