ural1014 Product of Digits (枚举)
来源:互联网 发布:程序员去汽车厂 编辑:程序博客网 时间:2024/06/17 13:45
从9到2对原来的数进行试除,除完之后若不等于1,则无解,否则将之前的试除出来的因子从小到大输出。特殊情况:0的时候为10,1的时候为1。
#include <bits/stdc++.h>using namespace std;int a[100];int m;int main() { int n; scanf("%d", &n); if (n == 0) { printf("10\n"); } else if (n == 1) { printf("1\n"); } else { m = 0; for (int i = 9; i > 1; i--) { while (n % i == 0) { a[m++] = i; n /= i; } } if (n != 1) { printf("-1\n"); } else { sort(a, a + m); for (int i = 0; i < m; i++) { printf("%d", a[i]); } printf("\n"); } } return 0;}
0 0
- ural1014 Product of Digits (枚举)
- Ural1014-Product of Digits
- URAL1014 - Product of Digits - 数论
- 1014. Product of Digits
- 993 - Product of digits
- 993 - Product of digits
- uva993 Product of digits
- 1014. Product of Digits
- ural 1014 Product of Digits
- TIMUS 1014. Product of Digits
- UVa 993 - Product of digits
- UVa 993 - Product of digits
- uva 993 - Product of digits
- uva 993 - Product of digits
- UVA 993 Product of digits
- UVa 993 - Product of digits
- Uva 993 Product Of Digits
- UVA 993 - Product of digits
- HDU1969-Pie
- POJ 3366 Deli Deli 可能会
- MDK环境下stm32实现printf函数
- 面试题16:反转链表
- [POJ]2739-Sum of Consecutive Prime Numbers
- ural1014 Product of Digits (枚举)
- 最小生成树---->prim算法的应用 hdu1863
- PAT A1056. Mice and Rice (25)
- ubuntu16.04忘记密码处理方法
- Codeforces Round #399 (Div. 1 + Div. 2, combined)C. Jon Snow and his Favourite Number
- 各项知识链接集合(比较杂)
- [HTC Vive + Unity开发]——VRTK的研究——用手柄旋转物体(使用VRTK_Knob脚本)
- TCP/IP 多播和多播路由
- bootstrap折叠调用collapse()后data-parent不生效问题