Cod sursa(job #1941507)
| Utilizator | Data | 27 martie 2017 12:53:22 | |
|---|---|---|---|
| Problema | Fractal | Scor | 70 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.76 kb |
#include <fstream>
using namespace std;
long long k,x,y,L,sol;
ifstream fin ("fractal.in");
ofstream fout ("fractal.out");
int main (){
// 1 4
// 2 3
fin>>k>>x>>y;
L = (1<<k);
swap (x,y);
while (L!=1){
L/=2;
if (x <= L){
if (y > L){
sol += 3*L*L; // merge 3 cadrane pana acolo (e in 4)
x = 2*L-y+1;
y = L-x+1;
continue;
}
swap (x,y);
continue;
}
if (y <= L){
sol += L*L; // un cadran
x -= L;
continue;
}
sol += L*L*2; // doua cadrane
x -= L;
y -= L;
}
fout<<sol;
return 0;
}
