Cod sursa(job #1354022)
Utilizator | Data | 21 februarie 2015 15:20:33 | |
---|---|---|---|
Problema | Fractal | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 1.05 kb |
#include <fstream>
using namespace std;
ifstream f("fractal.in");
ofstream g("fractal.out");
int k,t,s,x,y,i,aux;
int main()
{
f>>k>>y>>x;
t=1;
for(i=1;i<=k;i++)
t=t*2;
while(k>0){
if(x<=t/2){
if(y<=t/2){
aux=x;
x=y;
y=aux;
}
else{
s+=3*t*t/4;
y-=t/2;
aux=t/2-x+1;
x=t/2-y+1;
y=aux;
}}
else{
if(y<=t/2){
s+=t*t/4;
x-=t/2;
}
else{
s+=t*t/2;
x-=t/2;
y-=t/2;
}
}
k--;
t=t/2;
}
g<<s;
return 0;
}