比赛 Asm.Def战记之圣地亚哥“杯2015 评测结果 AAAAAATTTT
题目名称 Asm.Def的命令 最终得分 60
用户昵称 VG|Kn. 运行时间 40.256 s
代码语言 C++ 内存使用 2.22 MiB
提交时间 2015-10-31 11:27:12
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

const double pi = 3.14;
const int maxn = 100000 + 100;
int n, q;
int cz[maxn];
int a, b, dx, dy, deg;

struct person
{
	double x;
	double y;
}p[maxn];

void cz0(int u)
{
	printf("%.1f %.1f\n", p[u].x, p[u].y);
}

void cz1(int e, int f, int g, int h)
{
	for (int i = e; i <= f; i++)
	{
		p[i].x += g;
		p[i].y +=h;
	}
}

void cz2(int u, int v, int w)
{
	int xx, yy;
	double z = w * pi / 180;
	for (int i = u; i <= v; i++)
	{
		xx = p[i].x;
		yy = p[i].y;
		p[i].x = xx * cos(z) - yy * sin(z);
		p[i].y = xx * sin(z) + yy * cos(z);
	}
}

int main()
{
	freopen("asm_command.in","r",stdin);
	freopen("asm_command.out","w",stdout);
	cin >> n >> q;
	for (int i = 1; i <= n; i++)
	{
		p[i].x = 0;
		p[i].y = i;
	}
	for (int i = 1; i <= q; i++)
	{
		cin >> cz[i];
		if (cz[i] == 0)
		{
			cin >> a;
			cz0(a);
		}
		if (cz[i] == 1)
		{
			cin >> a >> b >> dx >> dy;
			cz1(a, b, dx, dy);
		}
		if (cz[i] == 2)
		{
			cin >> a >> b >> deg;
			cz2(a, b, deg);
		}
	}
	return 0;
}