首页 > 其他分享 >The number of divisors(约数) about Humble Numbers

The number of divisors(约数) about Humble Numbers

时间:2024-02-20 19:11:08浏览次数:32  
标签:约数 about humble Humble number long n% Input divisors

  • A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.
  • Now given a humble number, please write a program to calculate the number of divisors about this humble number.For examle, 4 is a humble,and it have 3 divisors(1,2,4);12 have 6 divisors.
  • Input
  • The input consists of multiple test cases. Each test case consists of one humble number n,and n is in the range of 64-bits signed integer. Input is terminated by a value of zero for n.
  • Output
    For each test case, output its divisor number, one line per case.
  • Sample Input
  • 4
  • 12
  • 0
  • Sample Output
  • 3
  • 6
    • 正解用到了算数基本定理
      如果会了这个,问题就迎刃而解

      点击查看代码
      	long long n;
      	while(scanf("%lld",&n)&&n)
      	{
      		long long a,b,c,d;
      		for(a=0;n%2==0;n/=2)
      			a++;
      		for(b=0;n%3==0;n/=3)
      			b++;
      		for(c=0;n%5==0;n/=5)
      			c++;
      		for(d=0;n%7==0;n/=7)
      			d++;
      		printf("%lld\n",(1+a)*(1+b)*(1+c)*(1+d));
      	}
      

标签:约数,about,humble,Humble,number,long,n%,Input,divisors
From: https://www.cnblogs.com/wlesq/p/18023855

相关文章

  • Humble Numbers
    打的暴力,样例都要过好久,小脑直接萎缩©©VjudgeAnumberwhoseonlyprimefactorsare2,3,5or7iscalledahumblenumber.Thesequence1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,...showsthefirst20humblenumbers.Writeapro......
  • 对最大公约数求法和扩展欧几里得算法的简要概述
    目录1.最大公约数(gcd)1.1更相减损术时间复杂度分析1.2辗转相除法(欧几里得算法)时间复杂度分析2.最小公倍数(lcm)3.裴蜀定理(贝祖定理)3.1扩展欧几里得算法(exgcd)1.最大公约数(gcd)数论中,通常用\(d\|\a\)表示\(d\)能整除\(a\),即\(......
  • Go 100 mistakes - #9: Being confused about when to use generics
    Go1.18addsgenericstothelanguage.Inanutshell,thisallowswritingcodewithtypes thatcanbespecifiedlaterandinstantiatedwhenneeded. Onelastthingtonoteabouttypeparametersisthattheycan’tbeusedwith methodarguments,onlywith......
  • 最大公约数和最小公倍数
    一、问题描述P1029[NOIP2001普及组]最大公约数和最小公倍数问题二、问题简析2.1最大公约数求两个正整数的最大公约数gcd(greatestcommondivisor),最常用的方法是辗转相除法。//求a和b的最大公约数intgcd(inta,intb){ if(b==0)returna; returngcd(a,......
  • About me
    山东2028级OIer。很菜。OIerDbhttps://oier.baoshuo.dev/oier/124413QQid=1427746949欢迎来加!洛谷uid=448881CodeForcesAtCoder......
  • 【算法专题】约数个数
    约数个数约数个数的普通求法首先我们根据数的唯一分解定理,对\(N\)进行分解得:\[N=p_1^{c_1}\timesp_2^{c_2}\timesp_3^{c_3}\times...\timesp_k^{c_k}\]由约数的定义:\(p_1^{c_1}=p_1^{0}\timesp_1^{1}\timesp_1^{2}\times...\timesp_1^{c_1}\)共有\(c_1......
  • A Literature Survey about Why Is Prompt Tuning for Vision-Language Models Robust
    I.SummaryOverviewBackground:Avision-languagemodelcanbeadaptedtoanewclassificationtaskthroughfew-shotprompttuning.Wefindthatsuchaprompttuningprocessishighlyrobusttolabelnoises.Interest:Studyingthekeyreasonscontributing......
  • P1029 最大公约数和最小公倍数问题
    321上题目链接:P1029[NOIP2001普及组]最大公约数和最小公倍数问题本小蒟蒻的原始思路就是枚举所有范围内的数,分别求出他们的最大公约数和最小公倍数,再看是否满足题意。于是就有了以下一言难尽的东西(;′⌒`)↓#include<stdio.h>intmain(){intx,y,count;sc......
  • 问题:What is this passage mainly about
    问题:WhatisthispassagemainlyaboutA.DemonstratingtheseriousweatherconditionaroundLakeChad.B.Introducingpeople'sactivityaroundLakeChad.C.AnalyzingofthefactorsthatcausewaterdecreasesinLakeChad.D.Introducingscientists'work......
  • 求最大公约数
    欧几里得算法基础:设有几个数\(a,b,c\)若\(a|b\)且\(a|c\)则\(a|b+c\)故而我们可以推出\(a|xb+yc\)我们可以推出\((a,b)=(b,a\modb)\)注:()是括号内两个数公约数集合​ |是整除得意思。证明:因为\(a\modb==a-[\fracab]*b\)故而我们根据上述定理。设左边任何一个公约......