uva993
来源:互联网 发布:基于时间的sql注入 编辑:程序博客网 时间:2024/05/16 09:37
题目大意:
给出一个数字,找出最小的可以满足每个数乘积等于它的数。
思路:
从9到2的找,因为这样才可以保证尽可能的小,不断的求余。
代码:
#include <iostream>using namespace std;#include <stdio.h>#include <cstring>int main() { int cases,N,Q,count1,a[10]; bool flag; scanf("%d",&cases); while(cases--) { memset(a,0,sizeof(a)); flag = false; scanf("%d",&N); if(N ==0 ) { printf("0\n"); continue; } if(N == 1) { printf("1\n"); continue; }// count1 = 0; for(int i = 9; i >= 2; i--) { while(N%i == 0){ N /= i; ++a[i]; //flag = true; // break; } } if(N == 1) { for(int i = 2; i < 10; i++) for(int j = 0 ; j < a[i]; j++) printf("%d",i); } else printf("-1"); printf("\n"); } return 0;}
0 0
- UVa993
- UVA993
- uva993
- uva993
- uva993
- uva993 Product of digits
- [模拟]uva993 Product of digits
- uva993 - Product of digits-------------水题 1A
- uva993 - Product of digits(数字之积)
- SQL语句
- LeetCode 083 Remove Duplicates from Sorted List
- 简单三层登录
- java 集合(4) List接口 / List 常用算法
- [实例]网页定位导航
- uva993
- 获取全局的Application对象
- hdoj4268Alice and Bob【贪心+二分】
- EventBus详解
- java 集合(5) 类对象排序 / 类实现Comparable 接口 / 调用Collections 类sort()
- 据说年薪30万的Android程序员必须知道事
- Hadoop core-site.xml 配置项清单
- jQuery中DOM操作
- XStream对xml文件序列化示列