当前位置:网站首页>求因子数量
求因子数量
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);
}
}
边栏推荐
猜你喜欢

深度学习入门之GRU

【 Harmony OS 】 【 ano UI 】 lightweight data storage

用scikit-learn学习谱聚类

Harmony OS ets ArkUI 】 【 】 the development basic page layout and data connection

idea uses @Autowired annotation to explain the reasons and solutions

typescript39-class类的可见修饰符

Kaggle 入门(Kaggle网站使用及项目复现)

Ali cloud object storage oss private barrels to generate links
![[Harmony OS] [ArkUI] ets development graphics and animation drawing](/img/36/f4c91f794b1321f11a24505d1617fb.png)
[Harmony OS] [ArkUI] ets development graphics and animation drawing

typescript45-接口之间的兼容性
随机推荐
2.ROS通信机制
NotImplementedError: file structure not yet supported
Flink state
1079 延迟的回文数 (20 分)
《录取通知》 观后感
User password encryption tool
Lambda表达式案例
High availability, two locations and three centers
阿凡提的难题
MySql数据库
1. 两数之和
轨迹(形状)相似性判断与度量方法
Ali cloud object storage oss private barrels to generate links
在树莓派上搭建属于自己的网页(2)
Peptides mediated PEG DSPE of phospholipids, targeted functional materials - PEG - RGD/TAT/NGR/APRPG
1054 求平均值 (20 分)
2. 两数相加
ss-3.工程重构
typescript41-class类的私有修饰符
BIOTIN ALKYNE CAS: 773888-45-2 Price, Supplier