poj1426
来源:互联网 发布:小程序 json 双引号 编辑:程序博客网 时间:2024/05/16 10:36
这个吧!!!!
心路历程一开始,想构造,然后吧,gg,又看怎么同余定理,真的看不懂,但愿以后能看懂(去年很多看不懂的东西,今年能看懂了)
2.然后,看了个别人的dfs,一开始想成从给的数开始搜索,后来吧就gg,想不通。
3.最后看了大神的,是枚举1的个数,然后X10,或者X10+1的,最后,发现还有个问题,你需要给他设定个深度范围,不然会一直做下去。还有就是选到了一定要打标记,不然的话会其他的支路会持续做这个,然后输出奇奇怪怪的东西
4.样例和我的不一样,一度怀疑自己错了,后来,用大神的编译了一次看,是一样一样的。交了a了
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;long long n,flag ;void dfs(long long a , int t){ if(t == 19 || flag) return; if(a % n == 0){ printf("%I64d\n",a); flag = 1; return; } else{ dfs(10 * a , t + 1); dfs(10 * a + 1 , t + 1); } return;}int main(){ while(scanf("%I64d",&n),n){ flag = 0; long long a = n; dfs(1,0); } return 0;}
0 0
- poj1426
- poj1426
- POJ1426
- poj1426
- poj1426
- poj1426
- POJ1426
- poj1426
- poj1426
- poj1426
- poj1426
- poj1426
- POJ1426
- poj1426
- POJ1426
- POJ1426
- poj1426
- poj1426
- Contiki初探
- 设置导航条和状态栏的颜色
- Android编译系统参考手册
- 手写HASHMAP
- Tomcat error : Failed to start component [StandardEngine[Catalina].Standar 但是 maven install ok
- poj1426
- 三种快速排序算法以及快速排序的优化
- GC(6.其他)
- undefined symbol: PyFPE_jbuf的解决方案
- 工欲善其事,必先利其器之windows快捷键组合
- Python 字典:当索引不好用时
- WordPress 子主题的用法
- Medium 208题 Implement Trie (Prefix Tree)
- 终于把 MySQL 的主外键搞懂了