A题:换零钞
答案:74
题解:
一层for循环暴力枚举,略。
B题:激光样式
答案:2178309
题解:
——dfs暴力枚举即可。
代码:
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long ll;
ll ans;
//step代表要处理哪一台机器,pre表示上台机器是亮还是灭
//0表示灭,1表示亮
void dfs(int step,int pre)
{
if(step==31)
{
ans++;
return ;
}
if(pre==1)
dfs(step+1,0);
else
{
dfs(step+1,0);
dfs(step+1,1);
}
}
int main()
{
ans=0;
dfs(1,-1);
printf("%lld\n",ans)