POJ 1426
来源:互联网 发布:移动硬盘与mac不兼容 编辑:程序博客网 时间:2024/05/29 09:54
bps加上了同余剪枝的优化
#include<iostream>#include<queue>using namespace std;struct node{ char num[101]; int len, remain;};int visited[200];queue<node> q;int main(){ int n; node t; while(scanf("%d", &n) && n != 0) { int i; for (i = 0; i < n; i++) visited[i] = 0; while (!q.empty()) q.pop(); t.num[0] = '1'; t.remain = 1 % n; t.len = 1; q.push(t); while(1) { t = q.front(); q.pop(); if (t.remain % n == 0) break; t.num[t.len] = '0'; t.len++; t.remain = (t.remain * 10) % n; if (visited[t.remain] == 0) { q.push(t); visited[t.remain] = 1; } t.num[t.len - 1] = '1'; t.remain = (t.remain + 1) % n; if (visited[t.remain] == 0) { q.push(t); visited[t.remain] = 1; } } t.num[t.len] = 0; printf("%s\n", t.num); }// system("pause"); return 0;}
- poj 1426
- poj 1426
- POJ 1426
- POJ 1426
- poj 1426
- poj 1426
- poj 1426
- POJ 1426
- poj-1426
- poj 1426
- poj 1426
- 1426POJ
- poj 1426
- poj 1426
- poj--1426
- POJ 1426
- POJ 1426
- poj 1426
- 判断点在多边形内外的简单算法
- 真戏假做
- TableCellRenderer的一个例子
- java 调用 .net webservic
- restlet overview 1
- POJ 1426
- 详解android应用程序的反编译
- restlet overview 2
- NumberFormat 类
- restlet getting start 1
- 在eclipse中引入jdom
- 为CSDN添加友情链接
- do...while(0)的妙用
- Windows 8 VS Windows 7:开发团队对比