Pagini recente »
Rating Baltoi Teodor (teodor.baltoi)
|
Borderou de evaluare (job #174908)
|
summerround3
|
Istoria paginii runda/concurs123xyz
|
Cod sursă (job #513374)
Cod sursă (job
#513374)
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
ifstream fin("romb2.in");
ofstream fout("romb2.out");
int v1[4], v2[4],dx, dy, pas, x, y, n;
int main(){
fin>>n;
for (int i=0; i<n; ++i) {
fin>>dx>>dy>>pas>>x>>y;
x *= dy;
y *= dx;
dx *= dy;
v2[0] = -dx;
v1[1] = dx;
v2[2] = dx;
v1[3] = -dx;
int rs = 0;
for (int j=0;j<pas; ++j) {
int a = (x > y);
int b = (x + y > 0);
int q = (a << 1) ^ (a == b);
x <<= 1;
y <<= 1;
x += v1[q];
y += v2[q];
rs = (rs << 2) ^ q;
}
fout<<rs + 1<<endl;
}
return 0;
}