当前位置:网站首页>求因子数量
求因子数量
2022-08-03 05:10:00 【-JMY-】
题目描述
从键盘读入一个整数n(n<=100),请求出1~n的每个数的因子个数(求因子个数时,不含1和自己,比如10只有2个因子),每行一个打印出来。
输入
一个整数n
输出
n行,每行一个整数,代表了每个整数的因子个数
样例输入
10
样例输出
0 0 0 1 0 2 0 2 1 2
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,s;
scanf("%d",&n);
for(int i=1;i<=n;i++){
s=0;
for(int j=2;j<=sqrt(i);j++)
if(i%j==0)
s+=2;
if(float(sqrt(i))==int(sqrt(i))&&i!=1)
s--;
printf("%d\n",s);
}
}
边栏推荐
- C# async and multithreading
- 嵌入式-I2C-物理电路图
- typescript45-接口之间的兼容性
- [Harmony OS] [ARK UI] ETS context basic operations
- Common fluorescent dyes to modify a variety of groups and its excitation and emission wavelength data in the data
- 0.ROS常用命令
- 用scikit-learn学习谱聚类
- 1060 爱丁顿数 (25 分)
- 曲线特征----曲线弯曲程度的探究
- 1094 谷歌的招聘 (20 分)
猜你喜欢

Power button 561. An array of split

Redis6学习笔记

C-PHY速率

嵌入式-I2C-物理电路图

【Harmony OS】【ARK UI】ets use startAbility or startAbilityForResult to invoke Ability

曲线特征----曲线弯曲程度的探究
breed Web刷机升级详细教材修正编译器固件说明_itkeji.top

Secondary development of WinForm controls
![[Harmony OS] [ArkUI] ets development graphics and animation drawing](/img/36/f4c91f794b1321f11a24505d1617fb.png)
[Harmony OS] [ArkUI] ets development graphics and animation drawing

2.ROS通信机制
随机推荐
2. 两数相加
Redis6学习笔记
【特征选取】计算数据点曲率
vim命令
Pr第三次培训笔记
Talking about GIS Data (6) - Projected Coordinate System
idea使用@Autowired注解爆红原因及解决方法
web安全-SSTI模板注入漏洞
shell脚本循环语句
Ali cloud object storage oss private barrels to generate links
2022暑假牛客多校联赛第一场
《录取通知》 观后感
IO流及其操作
Tributyl-mercaptophosphane "tBuBrettPhos Pd(allyl)" OTf), 1798782-17-8
2.ROS通信机制
Harmony OS ets ArkUI 】 【 】 the development basic page layout and data connection
获取Ip工具类
详解Nurbs曲线
celery工作原理图
1058 选择题 (20 分)(C语言)