1 solutions

  • 0
    @ 2024-12-18 17:50:55

    【算法分析】 暴力枚举每个位置上的数目

    使用一个位运算来储存所有的状态。 【代码实现】

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    int ans=0;	
    LL n;
    void dfs(LL x,int f)
    {
    	if(x>n) return ;
    	if(f==7) ans++;//说明x符合要求
    	dfs(x*10+3,f|4);
    	dfs(x*10+5,f|2);
    	dfs(x*10+7,f|1); 
    } 
    int main()
    {
    	cin>>n;
    	dfs(0,0);
    	cout<<ans;
    	return 0;
    }
    
    • 1

    Information

    ID
    1902
    Time
    2000ms
    Memory
    1024MiB
    Difficulty
    5
    Tags
    # Submissions
    1
    Accepted
    1
    Uploaded By