章三例题5——UVA 1583 Degit Generator
来源:互联网 发布:电气专业软件 编辑:程序博客网 时间:2024/06/14 21:26
题意就是如果x加上x的各个数字的和得到y,则说x是y的生成元,然后告诉y,求x的最小生成元。
然后因为n比较小,然后只用输入一组,直接枚举是可以过的。
据说可以打表,现在还没有接触到
http://blog.csdn.net/a27038/article/details/55048971
代码
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int main(){ int n; scanf("%d",&n); while(n--) { int N; scanf("%d",&N); int len=1; int flag=0; int temp=N; while(temp) { if(temp/10!=0) len++; temp=temp/10; } int j=0; for(int i=N-len*10;i<N;i++) { j=i; int g=i; while(g) { j+=g%10; g=g/10; } if(j==N) { flag=1; cout<<i<<endl; break; } } if(flag==0) printf("0\n"); } return 0;}
0 0
- 章三例题5——UVA 1583 Degit Generator
- UVa 1583 Digit Generator(例题3-4)
- 章三例题2——UVA 10082
- 章三例题3——UVA 401 Palindromes
- 章三例题6——UVA 1584
- 章三例题4——UVA 340 Master -Mind Hints
- 章三例题1 UVA 272
- Problem 005——UVa 1583 - Digit Generator
- UVA-1583 - Digit Generator
- UVa 1583 Digit Generator
- UVa 1583 - Digit Generator
- UVA 1583 - Digit Generator
- UVa 1583 Digit Generator
- UVa 1583 - Digit Generator
- UVa-1583Digit Generator
- 【Uva 1583】 Digit Generator
- UVA - 1583 Digit Generator
- Uva - 1583 - Digit Generator
- PAT乙级1017. A除以B (20)
- 职场的青春谁主沉浮
- [LeetCode] 95. Unique Binary Search Trees II & I
- 扫雷小游戏
- matlab行向量,列向量
- 章三例题5——UVA 1583 Degit Generator
- PAT甲级1018. Public Bike Management (30)
- SOJ 1015
- 2017ife_yaoyao学院_task2
- javascipt监听事件
- rem布局
- Python学习之[7]——python pickle模块
- 算法竞赛入门经典 第二版 习题5-4 交换学生 Foreign Exchange uva10763
- 网络麻将游戏