HDU1492-The number of divisors(約數) about Humble Numbers-數論(計數問題),divisorsnumbers-

來源:互聯網
上載者:User

HDU1492-The number of divisors(約數) about Humble Numbers-數論(計數問題),divisorsnumbers-

題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=1492

題意:給出一個只包含質因數2,3,5,7的數,求其約數的個數思路:如果n=p1^n1*p2^n2*...*pn^nn,其中p1,p2,...,pn表示質因數,n1,n2,...,nn表示相應質因數的指數,根據乘法原理,則約數的個數為(n1+1)(n2+1)...(nn+1)
#include<iostream>#include<string>#include<cstdio>#include<cstring>#include<map>#include<queue>#include<cmath>#include<stack>#include<set>#include<vector>#include<algorithm>#define LL long long#define inf 1<<29#define s(a) scanf("%I64d",&a)#define CL(a,b) memset(a,b,sizeof(a))using namespace std;const int N=200005;__int64 n,m,a,b,c,d;int main(){    while(s(n)&&n){        a=1,b=1,c=1,d=1;        while(n!=1&&n%2==0){a++,n/=2;}        while(n!=1&&n%3==0){b++,n/=3;}        while(n!=1&&n%5==0){c++,n/=5;}        while(n!=1&&n%7==0){d++,n/=7;}        printf("%I64d\n",a*b*c*d);    }    return 0;}


 

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.