博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
The Last Practice
阅读量:5124 次
发布时间:2019-06-13

本文共 1987 字,大约阅读时间需要 6 分钟。

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
 
 
1 #include 
2 #include
3 4 int main(){ 5 int number; 6 int i; 7 int amount[65536]; 8 int temp; 9 int time;10 11 time=1;12 13 while(1){14 scanf("%d",&number);15 16 if(number<0)17 break;18 19 if(time!=1)20 printf("\n");21 22 memset(amount,0,65536*sizeof(int));23 temp=number;24 25 while(1){26 for(i=2;i<=temp;i++){27 if(temp%i==0){28 amount[i]++;29 temp/=i;30 break;31 }32 33 }34 35 if(temp==1)36 break;37 }38 39 printf("Case %d.\n",time);40 time++;41 42 for(i=2;i<=number;i++){43 if(amount[i]!=0){44 printf("%d %d ",i,amount[i]);45 }46 }47 48 printf("\n");49 }50 51 return 0;52 }

 

转载于:https://www.cnblogs.com/zqxLonely/p/4085038.html

你可能感兴趣的文章
重启模块与及关开邮件存储设置功能页面-PHP-shell-py
查看>>
DNS协议详解
查看>>
[OJ] Matrix Zigzag Traversal
查看>>
2015-7.7森林探秘季
查看>>
千位分隔符的完整攻略
查看>>
PHP 递归删除目录中文件
查看>>
小甲鱼Python笔记(下)
查看>>
面试题19:二叉树镜像
查看>>
Android端实时音视频开发指南
查看>>
C++ 一键关闭屏幕
查看>>
关于生活
查看>>
基金基础知识
查看>>
loadrunner学习理论之一
查看>>
C++ 初始化列表初始化列表性能问题的简单的探索
查看>>
MyBatis入门
查看>>
曾国藩:诚敬静谨恒!
查看>>
ASP.NET数据格式的Format-- DataFormatString
查看>>
IOS+Android马甲包封装上架!
查看>>
【Immutable】拷贝与JSON.parse(JSON.stringify()),深度比较相等与underscore.isEqual(),性能比较...
查看>>
WPF - 自定义标记扩展
查看>>