当前位置:网站首页>Leshan normal programming competition 2020-h: least common multiple [find the number of factors]
Leshan normal programming competition 2020-h: least common multiple [find the number of factors]
2022-07-20 10:03:00 【Starry sky and bright moon】
Title Description
Given an integer b, in addition a Express 1 To 1018 All integers in , Calculation formula [a, b] / a How many different results , here [a, b] Represents an integer a And integers b The least common multiple of .
Input
The input contains only one set of data ;
The first line contains an integer b (1 ≤ b ≤ 1010).
Output
Output the number of different results of the formula .
The sample input
2
Sample output
2
Tips
Arbitrary positive integer a And 2 The least common multiple of must be equal to 2 * a perhaps a, So formula [a, b] / a The result can only be 1 perhaps 2.
Ideas
Enumerate more b, We will find that it is to ask b The number of factors .
for example b = 4;
(4, a) == > The least common multiple may be (a,2a,4a), Divided by a for (1,2,4), Observation shows that these are 4 Factor of .
So directly find the number of factors , however b There's a lot of scope , Observe again [1,sqrt(b)] There is this n Half of the factor ,(sqrt(b),n) There is another half , So we just need to enumerate to sqrt(b), Then find the number of factors , When enumerating to a factor , Another factor is found , If i * i It happens to be n, Then there is only one .
AC Code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll isPrime(ll n) {
ll cnt = 0;
for (ll i = 1; i <= sqrt(n); ++i) {
if (n % i == 0) {
if (i * i != n) {
cnt += 2;
} else {
cnt++;
}
}
}
return cnt;
}
void solve() {
ll b;
scanf("%lld", &b);
printf("%lld\n", isPrime(b));
}
int main() {
solve();
return 0;
}
边栏推荐
- 【Markdown】关于Markdown我想说这些~
- Master Karnaugh map simplification in one minute
- 三极管串联线性稳压电路原理详解及Multisim仿真
- PCL之圆形检测和直线检测
- 2022-7-15 第八小组 顾宇佳 学习笔记
- Leetcode:14. 最长公共前缀【思维+排序】
- C语言数据类型及typedef下的uint8_t / uint32_t
- FreeRTOS线程安全、中断安全的printf实现方式
- 解决问题phpstudy导入数据库失败
- When the vivado project version is upgraded, the relevant IP version IP status displays using cached IP results
猜你喜欢
Solution of STM32 cubeide breakpoint failure
Solution to the problem of constantly popping up blank web pages when opening OrCAD capture CIS in cadence 17.2
Secure Code Warrlor学习记录(四)
How to test the availability and stability of EIM bus
Add new display support to uboot of imx8m development board
离散数据(数组)的过零位置搜索
First hand evaluation of Reza g2l core board and development board
【Markdown】关于Markdown我想说这些~
最小二乘法线性拟合及其代码实现(C语言)
Infrared decoding program based on timer capture function (NEC protocol)
随机推荐
Master Karnaugh map simplification in one minute
关于在终端下使用npm命令,安装错误问题解决(自身经历)
FPGA skimming P4: use 8-3 priority encoder to realize 16-4 priority encoder, use 3-8 decoder to realize full subtracter, realize 3-8 decoder, use 3-8 decoder to realize logic function, and use data se
Least square linear fitting and its code implementation (C language)
内网渗透隧道技术的相关知识
Detailed explanation of tunnel and agent usage in SSH protocol
Leshan normal programming competition 2020-a: good pairs
Log access development with one person per day and nine people per day -- project development practice based on instruction set Internet of things operating system
【PTA】7-24 约分最简分式 (15 分)
Understanding of arm interrupt priority
Leetcode:905. 按奇偶排序数组【双指针+三种语言实现】
FPGA skimming P3: 4-bit numeric comparator circuit, 4bit carry ahead adder circuit, priority encoder circuit, priority encoder
Pearson correlation coefficient and code implementation (C language +matlab)
FPGA network port implementation and detailed explanation (3)
正则表达式的设计
Wireless network test based on Feiling NXP i.mx6ull
【PTA】 7-19 支票面额 (15 分)
Intelligent gateway based on Ruixin micro 3568 core board
Qt字符串操作
Redux main knowledge learning summary