hdu1405
来源:互联网 发布:excel软件下载2017 编辑:程序博客网 时间:2024/06/05 09:59
The Last Practice
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7905 Accepted Submission(s): 1624
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1405Problem Description
Tomorrow is contest day, Are you all ready?
We have been training for 45 days, and all guys must be tired.But , you are so lucky comparing with many excellent boys who have no chance to attend the Province-Final.
Now, your task is relaxing yourself and making the last practice. I guess that at least there are 2 problems which are easier than this problem.
what does this problem describe?
Give you a positive integer, please split it to some prime numbers, and you can got it through sample input and sample output.
We have been training for 45 days, and all guys must be tired.But , you are so lucky comparing with many excellent boys who have no chance to attend the Province-Final.
Now, your task is relaxing yourself and making the last practice. I guess that at least there are 2 problems which are easier than this problem.
what does this problem describe?
Give you a positive integer, please split it to some prime numbers, and you can got it through sample input and sample output.
Input
Input file contains multiple test case, each case consists of a positive integer n(1<n<65536), one per line. a negative terminates the input, and it should not to be processed.
Output
For each test case you should output its factor as sample output (prime factor must come forth ascending ), there is a blank line between outputs.
Sample Input
6012-1
Sample Output
Case 1.2 2 3 1 5 1Case 2.2 2 3 1Hint60=2^2*3^1*5^1解题思路:一提这道题就火大······以后水题纯属娱乐·······PE坑死了·······一点含金量都没有·········水成这样······直接看代码吧·····注意格式,每行最后都留一个空格·····完整代码:#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <sstream>#include <iomanip>#include <numeric>#include <cstring>#include <climits>#include <cassert>#include <complex>#include <cstdio>#include <string>#include <vector>#include <bitset>#include <queue>#include <stack>#include <cmath>#include <ctime>#include <list>#include <set>#include <map>using namespace std;#pragma comment(linker, "/STACK:102400000,102400000")typedef long long LL;typedef double DB;typedef unsigned uint;typedef unsigned long long uLL;/** Constant List .. **/ //{const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const LL INFF = 0x3f3f3f3f3f3f3f3fLL;const DB EPS = 1e-9;const DB OO = 1e20;const DB PI = acos(-1.0); //M_PI;const int maxn = 1000001;bool ispri[maxn];int pri[maxn];int t;void dopri(){ memset(ispri , true , sizeof(ispri)); t = 0; for(int i = 2; i <= maxn ; i ++) { if(ispri[i]) { pri[t ++] = i; for(int j = i * 2 ; j <= maxn ; j += i) ispri[j] = false; } }}int main(){ #ifdef DoubleQ freopen("in.txt","r",stdin); #endif int n; dopri(); int cas = 1; while(~scanf("%d",&n) && n > 1) { if(cas != 1) cout << endl; printf("Case %d.\n",cas++); int num = n; for(int i = 0 ; i < num ; i ++) { if( n == 1) break; int cnt = 0; while(n % pri[i] == 0) { cnt ++ ; n /= pri[i]; } if(cnt != 0) { printf("%d ",pri[i]); printf("%d ",cnt); } } printf("\n"); }}
0 0
- hdu1405
- hdu1405
- hdu1405
- HDU1405
- HDU1405:The Last Practice
- HDU1405 The Last Practice
- hdu1405 The Last Practice
- hdu1405 The Last Practice
- HDU1405-素数筛选
- HDU1405 The Last Practice
- hdu1405 后置0的个数
- The Last Practice(HDU1405)
- hdu1405——The Last Practice
- 动画预览
- 任意行数的数据输入表格
- uva 10128 Queue (dp)
- spring配置oracle多个用户的datasource
- IntelliMas环境搭建
- hdu1405
- spring配置oracle多个用户的datasource
- LeetCode Partition List
- ubuntu因“不完整的语言支持”更新后字体变难看的解决
- HDU 1863 畅通工程
- Hibernate配置数据库方言
- 【转】灰度Gray
- stm32时钟分析
- 小楼一阁的数据结构学习笔记(三、单链表)