hdu1164

2024-08-22 10:32
文章标签 hdu1164

本文主要是介绍hdu1164,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Eddy’s research I

*Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14666 Accepted Submission(s): 8935
*

Problem Description

Eddy’s interest is very extensive, recently he is interested in prime number. Eddy discover the all number owned can be divided into the multiply of prime number, but he can’t write program, so Eddy has to ask intelligent you to help him, he asks you to write a program which can do the number to divided into the multiply of prime number factor .

Input

The input will contain a number 1 < x<= 65535 per line representing the number of elements of the set.

Output

You have to print a line in the output for each entry with the answer to the previous question.

Sample Input

11
9412

Sample Output

11
2*2*13*181

Author

eddy

Recommend

JGShining | We have carefully selected several similar problems for you: 1215 1211 1061 1299 1163

代码

#include  <bits/stdc++.h>
using namespace std;int i;int main()
{int n;while(scanf("%d", &n)==1 ){bool flag =  false;for(i = 2; i  * i<= n; i ++){int cnt = 0;while(n % i== 0){cnt ++;n /= i;}if(cnt == 0){printf("");continue;}if(flag){putchar('*');}printf("%d",i);for(int i = 2; i <=cnt; i ++){printf("*%d", ::i);}flag = true;}if(n>1 ){if(flag) putchar('*');printf("%d", n);}printf("\n");}return  0;
}

这篇关于hdu1164的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1096016

相关文章

hdu1164 Eddy's research I(数论:唯一分解式)

一道很简单的水题有木有啊!! 我又TLE了好几次 原因是我用的是逗号表达式,今天听学长说了才知道,逗号表达式的结果就是最后一个逗号后表达式的结果 所以我的程序会一直判断正确,一直继续执行... 看到题目想都没想就用欧拉函数变形,TLE后我还以为真的是算法问题 想了想和打表差的也不多啊... 欧拉定理15ms: #include <math.h>#include <stdio.h