Cod sursa(job #2915007)

Utilizator superffffalexandru radu superffff Data 21 iulie 2022 16:26:33
Problema Fractal Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <fstream>
#include <cmath>
#include <math.h>
using namespace std;
ifstream in("fractal.in");
ofstream out("fractal.out");
int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,S,t,T,x,y,z,ok,nr,C,poz,Max;
void div(int m,int x,int y){
   if(m>1) {
        g--;
  if(x<=m/2) {
    if(y<=m/2) {
        div(m/2,y,x);
    }
    else {
        s=s+pow(4,g)*3;
        div(m/2,x,y-m/2);
    }
  }
  else {
     if(y<=m/2) {
        s=s+pow(4,g);
        div(m/2,x-m/2,y);
    }
    else {
        s=s+pow(4,g)*2;
        div(m/2,x-m/2,y-m/2);
    }
  }
   }
}
int main()
{
  in>>k>>y>>x;
  s=0;
  g=k;
  ok=1;
  div(1<<k,x,y);
   out<<s;
    return 0;
}