4.14 | 学习笔记
生活随笔
收集整理的這篇文章主要介紹了
4.14 | 学习笔记
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1.“雙階乘的質(zhì)因數(shù)個數(shù)”
之前想要開數(shù)組,把所有1到10000的雙階乘值都存好,然后再寫一個函數(shù)算出質(zhì)因子個數(shù),最后悲劇了
換個思路,每個因數(shù)中分別有多少個質(zhì)因數(shù)m,相加就好啦
#include<bits/stdc++.h> using namespace std; int T,n,m,tmp,cnt; int main() {cin>>T;for(int i=0;i<T;++i){cnt=0;cin>>n>>m;for(int j=n%2;j<=n;j+=2){tmp=j;while(tmp&&tmp%m==0)++cnt,tmp/=m;}cout<<"case #"<<i<<":\n"<<cnt<<endl;}return 0; }
2.大數(shù)求冪(理解不上去,先存?zhèn)€代碼)
#include<bits/stdc++.h> using namespace std; int a[100001]; int m,n,i,j; int main() {cin>>m>>n;a[0]=1,a[1]=1;for(i=1;i<=n;i++){for(j=1;j<=a[0];j++)a[j]*=m;for(j=1;j<=a[0];j++)//轉(zhuǎn)為高精加{a[j+1]+=a[j]/10;a[j]%=10;}if(a[a[0]+1]>0)a[0]++;//進(jìn)位}for(i=a[0];i>=1;i--)cout<<a[i];//倒序輸出return 0; }
轉(zhuǎn)載于:https://www.cnblogs.com/MissCold/p/10707463.html
總結(jié)
以上是生活随笔為你收集整理的4.14 | 学习笔记的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python之PIL库的运用、GIF处理
- 下一篇: jquery iCheck 插件