当前位置:网站首页>求因子数量
求因子数量
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);
}
}
边栏推荐
- Build your own web page on raspberry pie (1)
- 3. 无重复字符的最长子串
- UV decomposition of biotin - PEG2 - azide | CAS: 1192802-98-4 biotin connectors
- 2022暑假牛客多校联赛第一场
- typescript42-readonly修饰符
- C-PHY速率
- Common lipophilic cell membrane dyes DiO, Dil, DiR, Did spectrograms and experimental procedures
- 背压机制
- Kaggle 入门(Kaggle网站使用及项目复现)
- 【特征选取】计算数据点曲率
猜你喜欢
随机推荐
junit总结
odps的临时查询能在写sql的时候就给结果一个命名不?
User password encryption tool
Create a tree structure
Newifi路由器第三方固件玩机教程,这个路由比你想的更强大以及智能_Newifi y1刷机_smzdm
MCM box model modeling method and source analysis of atmospheric O3
轨迹(形状)相似性判断与度量方法
typescript44-对象之间的类兼容器
高效率科研神器——小软件、大能量
Common lipophilic cell membrane dyes DiO, Dil, DiR, Did spectrograms and experimental procedures
typescript42-readonly修饰符
1. 两数之和
FileZilla 搭建ftp服务器
业务表解析-余额系统
VSO Downloader Ultimate 5.0.1.45 中文多语免费版 在线视频下载工具
PotPlayer实现上班摸鱼电视自由
C# async and multithreading
Coordinate knowledge in digital twin campus scenarios
shell script loop statement
Install IIS services (Internet Information Services (Internet Information Services, abbreviated IIS, Internet Information Services)








