이거 너비탐색은


#include <iostream>

#include <queue>


using namespace std;




class structOfData{

public:

structOfData(int _depth) : depth(_depth){}

int depth;

};


int main(){

int depthCount = 0;

int totalValue = 0;

cin >> depthCount;

queue<structOfData> q;

q.push(structOfData(1));

while (!q.empty()){

int depth>

q.pop();

if (depthData < depthCount){

depthData++;

q.push(structOfData(depthData));

q.push(structOfData(depthData));

}

else{

totalValue++;

}

}

cout << totalValue << endl;


return 0;

}


재귀는

#include <iostream>


using namespace std;


void refunc(int _maxCount,int _nowCount, int& _totalValue){

if (_maxCount == _nowCount){

_totalValue++;

return;

}

else{

_nowCount++;

refunc(_maxCount, _nowCount, _totalValue);

refunc(_maxCount, _nowCount, _totalValue);

}

}


int main(){

int depthCount = 0;

int totalValue = 0;

cin >> depthCount;

refunc(depthCount,1, totalValue);

cout << totalValue << endl;

}


맞나? 이거 ㅇㅇ 말대로 단순히 방정식화 해서 나오긴 하는데 문제 유도가 컴퓨터한테 탐색하게 해서 결과값을 도출하는거 아니냐 방성식으로하면 한줄이면 되긴 할듯