poj 1426Find The Multiple
這真是超神奇的一道題目!樣例沒過,照樣ACCEPTED,看來我人品爆了。呵呵呵。。。本人還是覺得是樣例有問題的!
題目意思超簡單:找到任意n的倍數m,但是m由十進位制0,1組成。直接BFS。
程式碼:
#include<iostream>
using namespace std;
__int64 q[9999999];
int n;
void bfs()
{
int front,rear;
front=rear=0;
q[rear]=1;
rear++;
__int64 top;
while(front<rear)
{
top=q[front];
if(top%n==0){cout<<top<<endl;break;}
top*=10;
q[rear]=top;
rear++;
q[rear]=top+1;
front++;
rear++;
}
}
int main()
{
while(cin>>n,n)
{
bfs();
}
return 0;
}
相關文章
- POJ1426-Find The Multiple
- JavaScript select multipleJavaScript
- Logstash Multiple Pipelines
- Small Multiple(最短路)
- 2.3.6.2 Synchronization of Multiple ApplicationsAPP
- LLM multiple modal applicationsAPP
- kubernetes traefik multiple namespacesnamespace
- poj 2031
- poj 3461
- Multiple Books多賬薄
- poj 3278 BFS
- POJ 2975 Nim
- poj3417
- POJ 1089 Intervals
- POJ 3414 Pots
- Lowest Common Multiple Plus hd 2028
- Network(POJ-1144)
- POJ 2553 The Bottom of a Graph
- POJ 1861 Network (Kruskal)
- Apple Catching POJ - 2385APP
- POJ 1442 Black Box
- POJ 2799 IP Networks
- POJ3259-WormholesWorm
- POJ3414-Pots
- 【BFS】poj 3414 Pots
- HDU 6298 Maximum Multiple(找規律)
- sim3d multiple component example3D
- Road Construction(POJ-3352)Struct
- Redundant Paths(POJ-3177)
- The Cow Prom(POJ-3180)
- Network of Schools(POJ-1236)
- POJ3414 Pots【BFS】
- POJ 3071 Football(概率DP)
- [poj1275][Cashier Employment]
- POJ - 1125 Stockbroker Grapevine(Java)Java
- Dungeon Master(POJ-2251)AST
- POJ 1611 The Suspects 圖論圖論
- POJ 3267 The Cow Lexicon(dp)
- POJ3126-Prime Path