问大家一个问题,这题广搜过不了是咋回事
  • 板块P1988 火炬
  • 楼主黑影洞人
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/2/15 18:33
  • 上次更新2023/10/28 08:27:48
查看原帖
问大家一个问题,这题广搜过不了是咋回事
285617
黑影洞人楼主2022/2/15 18:33
#include<cstdio>
#include<queue>
#include<algorithm>
#define int long long
using namespace std;
int n,a[1145141],tot;
queue<int> q;
void dfs(int k){
	a[++tot]=k;
	if(k>9e17)return;
	dfs(k*10);dfs(k*10+1);
} 
signed main(){
    scanf("%lld",&n);
    /*q.push(1);
    while(q.size()){
        a[++tot]=q.front();
        q.pop();
        if(a[tot]>9e17)break;
        q.push(a[tot]*10);
        q.push(a[tot]*10+1);
    }*/
	 tot=0;dfs(1);
    sort(a+1,a+1+tot);
    for(int i=1;i<=tot;i++){
        if(a[i]%n==0){
            printf("%lld",a[i]/n);
            return 0;
        }
    }
    printf("No Solution");
    return 0;
}

广搜80分,深搜100分

2022/2/15 18:33
加载中...