水题
題目描述
輸入一個數(shù),輸出這個數(shù)的質(zhì)因中位數(shù)。定義:質(zhì)因中位數(shù)是所有質(zhì)因數(shù)(N次方則有N個)的中位數(shù)。如660=2*2*3*5*11,660的質(zhì)因中位數(shù)為3。
輸入
多組數(shù)據(jù)每行一個正整數(shù)(小于10^5,大于1),不超過1000組。輸出
每行一個整數(shù)(四舍五入)。樣例輸入
660樣例輸出
3提示
每行一個整數(shù)。
AC代碼:
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() {int i,n,b;int a[100];while(~scanf("%d",&n)){b=0;for(i=2;i<=n;i++)while(n%i==0){n/=i;a[b++]=i;}if(b%2==0){i=(a[b/2-1]+a[b/2]);if(i%2==0) printf("%d\n",i/2);else printf("%d\n",(i+1)/2); }else cout<<a[b/2]<<endl;} }總結(jié)
- 上一篇: JEECG_3.7 新版本视频正式发布
- 下一篇: 这题不错