poj 1426 Find The Multiple

http://162.105.81.212/JudgeOnline/problem?id=1426

 

 

Discuss里多说用bfs+状态压缩,

看了半天也没看出来(就是不会,囧)

只好暴力枚举-_-,62MS

 

#include<stdio.h> __int64 a[1500000]; int main() { int n,t1,t2; while(scanf("%d",&n),n) { t1=0; t2=1; a[0]=1; while(1) { if(a[t1]%n==0) { printf("%I64d/n", a[t1]); break; } else { a[t2++]=a[t1]*10; a[t2++]=a[t1]*10+1; t1++; } } } return 0; }

 

ps: 知道这题用bfs怎么解的留个言啊..TU

你可能感兴趣的:(poj 1426 Find The Multiple)