HDU 1405 The Last Practice【注意输出格式】

/*

中文题目 最后的练习

中文翻译-大意 举例说明60%2==0;60/2==30;30%2==0;30/2==15;15%2!=0;15%3==0;15/3==5;5%3!=0;5%5==0;根据例子可以看出60的质子含有2^2, 3^1, 5^1,按样例输出2【】2【】3【】1【】5【】1【】。

解题思路:先打一个素数表,在直接求解就可以了

注意:除第一个数据外,其余输入后要空行;输出格式坑人啊。

关键点:输出格式

解题人:lingnichong

解题时间:2014-08-29 00:33:47

解题体会:没看清题意,凭着感觉写输出,结果oj好不客气的给我个PE

*/

The Last Practice

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 7919    Accepted Submission(s): 1627

Problem 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.

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

60
12
-1

Sample Output

Case 1.
2 2 3 1 5 1

Case 2.
2 2 3 1

Hint

60=2^2*3^1*5^1

Author

lcy

Source

杭电ACM集训队训练赛(IV)

/*本题注意格式为如下
60
Case 1.
2 2 3 1 5 1
12

Case 2.
2 2 3 1
12

Case 3.
2 2 3 1
-1

--------------------------------
Process exited with return value 0
Press any key to continue . . .

*/

#include<stdio.h>
#include<string.h>
#define MAXN 65536+10
int a[MAXN],b[MAXN];
int main()
{
	int n,i,j,k=0,t=1;
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	a[0]=a[1]=-1;
	for(i=2;i<MAXN/2;i++)
	{
		for(j=2*i;j<MAXN;j+=i)
		if(a[j] != -1)
			a[j] = -1;
	}
	for(i=0;i<MAXN;i++)
	{
		if(a[i]==0)
		b[k++] = i;
	}
	while(scanf("%d",&n),(n>=0))
	{
		if(t>1)
		printf("\n");
		printf("Case %d.\n",t++);
		for(i = 0; i <= n/2; i++)
		{
			int count=0,flag=0;
			while(n%b[i]==0)
			{
				count++;
				n /= b[i];
				flag=1;
			}
			if(flag==1)
			printf("%d %d ",b[i],count);
		}
		printf("\n");
	}
	return 0;
} 
时间: 2024-08-07 01:39:04

HDU 1405 The Last Practice【注意输出格式】的相关文章

HDU 1405 The Last Practice(数学题,变态的格式)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1405 Problem 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 ch

HDU 1405 The Last Practice

The Last Practice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9226    Accepted Submission(s): 1960 Problem Description Tomorrow is contest day, Are you all ready?We have been training for 45

杭电 HDU ACM 1405 The Last Practice

The Last Practice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8374    Accepted Submission(s): 1724 Problem Description Tomorrow is contest day, Are you all ready? We have been training for

HDU 1017 A Mathematical Curiosity (输出格式,穷举)

#include<stdio.h> int main() { int N; int n,m; int a,b; int cas; scanf("%d",&N); while(N--) { cas=1;//必须在这儿初始化cas,坑 while(scanf("%d%d",&n,&m),n||m) { int count=0; for(a = 1; a < n; a++)//穷举法 { for(b = a + 1; b <

HDU 1405

题意: 输入一个数n,输出它的素因子与这个素因子出现的次数. 分析: 用欧拉函数,变下形就好了,不再过多解释. 代码如下: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <fstream> 5 #include <ctime> 6 #include <cmath> 7 #include <cstdlib> 8 #inclu

hdu 1094 A+B for Input-Output Practice (VI)

A+B for Input-Output Practice (VI) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 63087    Accepted Submission(s): 42387 Problem Description Your task is to calculate the sum of some integers.

hdu 1093 A+B for Input-Output Practice (V)

A+B for Input-Output Practice (V) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 67443    Accepted Submission(s): 45101 Problem Description Your task is to calculate the sum of some integers.

hdu 1092 A+B for Input-Output Practice (IV)

A+B for Input-Output Practice (IV) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 90793    Accepted Submission(s): 48215 Problem Description Your task is to Calculate the sum of some integers.

java hdu A+B for Input-Output Practice (III)

A+B for Input-Output Practice (III) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 113961    Accepted Submission(s): 60127 Problem Description Your task is to Calculate a + b. Input Input conta