跳到正文

题解

AT_abc114_c题解

XWCL_OI约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年6月1日
更新
2026年6月1日
篇幅
约 1 分钟
获赞
3

版本

  1. v1当前

思路:

使用 BFS 函数,并定义三个变量,分别代表 77、55、33 的个数,并使用 ans 来设定为总个数的计数器,随后定义一个变量 xx 表示为当前的数即可。

注意:xx 要开 long long!

code:

C++
#include<bits/stdc++.h>
using namespace std;
long long n,cnt=0,ans;
void dfs(long long x,int a,int b,int c)
{
	if(x>n)
	{
		return;
	}
	ans+=a&&b&&c;
	dfs(x*10+3,a+1,b,c);
	dfs(x*10+5,a,b+1,c);
	dfs(x*10+7,a,b,c+1);
	
}
int main()
{
	cin>>n;
	dfs(0,0,0,0);
	cout<<ans<<endl;
	return 0;
}
原文
抓取于
  1. littlesnake

    《BFS》

  2. Quija

    大佬我想请问为什么a&&b&&c能达到计数的目的?

  3. T0urist

    Orz

  4. lrqlrq250

    《使用BFS函数》

  5. LBYYSM_123

    你这不是使用使用 DFS 函数 吗

  6. XWCL_OI

    qp