日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

数学概念——J - 数论,质因数分解

發布時間:2025/3/15 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 数学概念——J - 数论,质因数分解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
J -?數論,質因數分解 Time Limit:1000MS?????Memory Limit:32768KB?????64bit IO Format:%I64d & %I64u Submit?Status

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

解題思路:
這個題目很簡單,但是要注意一個陷井,就是輸入一個數的時候,它的結束條件是負數,一定要注意
程序代碼: #include <cstdio> #include <cstring> using namespace std; int b[66550]; int n; void p( ) {int m=n;while(1){for(int i=2;i<=n;i++ )if(m%i==0){b[i]++;m/=i;break;}if(m==1)break;}} int main() {int Case=0;while(scanf("%d",&n)==1&&n>0){if(Case>0) printf("\n");memset(b,0,sizeof(b));p();printf("Case %d.\n",++Case);for(int i=2;i<=n;i++)if(b[i]!=0)printf("%d %d ",i,b[i]);printf("\n");} } View Code

?



轉載于:https://www.cnblogs.com/www-cnxcy-com/p/4750476.html

總結

以上是生活随笔為你收集整理的数学概念——J - 数论,质因数分解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。