Cod sursa(job #3143427)
| Utilizator | Data | 29 iulie 2023 23:58:09 | |
|---|---|---|---|
| Problema | Fractal | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.98 kb |
#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int k, i, j, x, y, sol, n;
int main(){
fin >> k >> j >> i;
int t;
while(k > 0){
k--;
t = (1 << k);
n = t * t;
if(i <= t && j <= t){
x = j;
y = t - i + 1;
y = t - y + 1;
i = x;
j = y;
}else{
if(i <= t && j > t){
j -= t;
x = t - j + 1;
y = i;
y = t - y + 1;
i = x;
j = y;
sol += n * 3;
}else{
if(i > t && j <= t){
i -= t;
sol += n;
}else{
i -= t;
j -= t;
sol += 2 * n;
}
}
}
}
fout << sol;
return 0;
}
