HDU 1405 第六周 J题
Description
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
Output
Sample Input
12
-1
Sample Output
2 2 3 1 5 1
Case 2.
2 2 3 1
Hint
60=2^2*3^1*5^1 题意:如Hint所示.....,但是他的输出比较坑爹,开始一直不对然后没办法去百度了一下,大神说在输出结果最后还有空格,注意有空格!卧槽.... 反正我是没有看出来 题解:就是求质因数,通过循环求质因数,如果n可以除尽i,进入while语句求i的次方,再用数组记录下来,最后在输出数组就好了... 代码如下:(详情见注释)
#include <stdio.h>
int ans[];
int main()
{
int n,N=;
while(scanf("%d",&n)==&&n>=)
{
int j=;
if(N)
printf("\n"); //换行
N++;
for(int i=; i<=n; i++)
{
if(n%i==) //如果可以除尽
{
int m=; //注意清零
while(n%i==) //循环求 次数
{
m++;
n=n/i;
}
ans[j++]=i; //依次储存下来
ans[j++]=m;
}
}
printf("Case %d.\n",N); for(int k=; k<j; k++)
printf("%d ",ans[k]); //输出
printf("\n");
}
}
HDU 1405 第六周 J题的更多相关文章
- hdu 4548 第六周H题(美素数)
第六周H题 - 数论,晒素数 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u De ...
- HDU 1465 第六周L题
Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了! 做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样. ...
- HDU 2669 第六周 I题
Description The Sky is Sprite. The Birds is Fly in the Sky. The Wind is Wonderful. Blew Throw the ...
- hdu1405 第六周J题(质因数分解)
J - 数论,质因数分解 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Desc ...
- 程序设计入门—Java语言 第六周编程题 1 单词长度(4分)
第六周编程题 依照学术诚信条款,我保证此作业是本人独立完成的. 1 单词长度(4分) 题目内容: 你的程序要读入一行文本,其中以空格分隔为若干个单词,以'.'结束.你要输出这行文本中每个单词的长度.这 ...
- 2014 HDU多校弟六场J题 【模拟斗地主】
这是一道5Y的题目 有坑的地方我已在代码中注释好了 QAQ Ps:模拟题还是练的太少了,速度不够快诶 //#pragma comment(linker, "/STACK:16777216&q ...
- Codeforces 559A 第六周 O题
Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angle ...
- 第六周 N题
Description As Harry Potter series is over, Harry has no job. Since he wants to make quick money, (h ...
- HDU1465 第六周L题(错排组合数)
L - 计数,排列 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Descrip ...
随机推荐
- iOS开发libWeChatSDK.a(WXApiObject.o)' does not contain bitcode.
在使用微信分享的时候可能会报错, 报错如下: ld: '/Users/gti/Documents/********/Lib/SDKExport/libWeChatSDK.a(WXApiObject.o ...
- 【CSS】class和id命名规则
说明,本篇内容为书籍<高流量网站CSS开发技术>的学习总结,文字出自书本 书不错,推荐阅读学习 也可参阅网上的博文 原载:彬Go链接:http://blog.bingo929.com/cs ...
- Tornado web.authenticated 用户认证浅析
在Web服务中会有用户登录后的一系列操作, 如果一个客户端的http请求要求是用户登录后才能做得操作, 那么 Web服务器接收请求时需要判断该请求里带的数据是否有用户认证的信息. 使用Tornado框 ...
- Application Loader上传app时报错:the bundle identifier cannot be changed from the current value
报错如图: 解决:用info.plist中的bundle identifier生成发布证书(Distribution),如图:
- 百度地图LBS开放平台AK一直没有用
http://api.map.baidu.com/geoconv/v1/?coords=114.21892734521,29.575429778924;114.21892734521,29.57542 ...
- DWZ (JUI) 教程 国际化问题(多语言/语言切换)
DWZ 国际化也是比较简单的,网站的内容国际化和常规的项目国际化是一样的,不要做出特殊的调整. DWZ 自身框架的国际化,比如 翻页的上一页下一页等信息.这些信息都是在dwz.frag.xml 文件当 ...
- 如何判断单选按钮radio被选中
今天要写一个单选按钮选中之后显示某些内容,首要问题就是当选中如何获取到值! html代码如下 <input class="joined" type="radio&q ...
- iOS-GCD多线程
GCD GCD -- Grand Central Dispatch 是基于C语言的底层API 用Block定义任务,将任务添加到线程中使用.集中管理 1.GCD的执行函数 //同步 dispatch_ ...
- WPF密码框中禁止复制、粘贴
如题: " Margin="215,32,151,0" > <PasswordBox.CommandBindings> <CommandBindi ...
- 字符集转换: Ansi - Unicode
字符集转换: Ansi - Unicode wstring AnsiToUnicode (const string& strSrc ) { /*!< 分配目标空间 */ ,strSrc. ...