Pentru această operație este nevoie să te autentifici.

Cod sursă (job #513369)

Utilizator avatar PascalSergiu Sergiu Pascal PascalSergiu IP ascuns
Problemă Romb2 (clasele 9-10) Compilator cpp | 0,70 kb
Rundă Arhiva de probleme Status evaluat
Dată 16 dec. 2019 17:46:23 Scor 0
#include <bits/stdc++.h>
 
using namespace std;
 
ifstream f("romb.in");
ofstream g("romb.out");
int dx, dy, k, cx, cy, t;
long long sol(long long zona, double dx, double dy, double cx, double cy)
{
	if(k==0)
	{
		return zona;
	}
	k--;
	if(cx*dy<cy*dx)
	{
		if(cx*dy<(-cy*dx))
		{
			return sol(4*zona-2, dx/2, dy/2, cx+dx/2, cy);
		}
		else
		{
			return sol(4*zona-3, dx/2, dy/2, cx, cy-dy/2);
		}
	}
	else
	{
		if(cx*dy>-(cy*dx))
		{
			return sol(4*zona, dx/2, dy/2, cx-dx/2, cy);
		}
		else
		{
			return sol(4*zona-1, dx/2, dy/2, cx, cy+dy/2);
		}
	}
}
int main()
{
	f>>t;
	while(t--)
	{
		f>>dx>>dy>>k>>cx>>cy;
		g<<sol(1,dx,dy,cx,cy)<<'\n';
	}
	return 0;
}