求大佬看p1988 我100分但是输入999错了
查看原帖
求大佬看p1988 我100分但是输入999错了
537566
我和我的祖国楼主2023/10/5 16:10
#include<bits/stdc++.h>
using namespace std;
long long ans,n;
queue<long long> q;
void bfs() {
	q.push(1L);
	while(q.size()) {
		long long t=q.front();
		q.pop();
		if(t%n==0&&t>=n) {
			cout<<t/n<<endl;
			return;
		}
		if(ans>=10000100) {
			cout<<"No Solution"<<endl;
			return;
		}
		ans++;
		q.push(t*10);
		q.push(t*10+1);
	}
} 
int main() {
	cin>>n;
	bfs();
	return 0;
}
2023/10/5 16:10
加载中...