当前位置:网站首页>求因子数量
求因子数量
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);
}
}
边栏推荐
- Length n of condensed distance matrix ‘y‘ must be a binomial coefficient
- User password verification
- OptionError: ‘Pattern matched multiple keys‘
- Super handy drawing tool is recommended
- 在树莓派上搭建属于自己的网页(2)
- Tributyl-mercaptophosphane "tBuBrettPhos Pd(allyl)" OTf), 1798782-17-8
- UV decomposition of biotin - PEG2 - azide | CAS: 1192802-98-4 biotin connectors
- Flask的简单介绍及使用方法简介
- 2017-06-11 Padavan 完美适配newifi mini【adbyby+SS+KP ...】youku L1 /小米mini
- 高可用 两地三中心
猜你喜欢

用scikit-learn学习谱聚类

Js学习笔记(四)

tag单调栈-单调栈预备知识-lt.739. 每日温度

Modelarts第一次培训

junit总结

Coordinate knowledge in digital twin campus scenarios

idea使用@Autowired注解爆红原因及解决方法

【 Harmony OS 】 【 ano UI 】 lightweight data storage

Fluorescent marker peptides FITC/AMC/FAM/Rhodamine TAMRA/Cy3 / Cy5 / Cy7 - Peptide
网络流媒体下载的 10 种方法(以下载 Echo 音乐为例)
随机推荐
idea uses @Autowired annotation to explain the reasons and solutions
web安全-命令执行漏洞
第三次HarmonyOS培训
Odps temporary query can write SQL, turned out to a named?
ss-1.curl (cloud-provider-payment8001)
Business table analysis - balance system
typescript49-交叉类型
2022暑假牛客多校联赛第一场
反射注解基础
Coordinate knowledge in digital twin campus scenarios
Benchmark 第一篇 了解Benchmark
建造者模式(Builder Pattern)
Installation of Apache DolphinScheduler version 2.0.5 distributed cluster
Common fluorescent dyes to modify a variety of groups and its excitation and emission wavelength data in the data
MySql数据库
Install IIS services (Internet Information Services (Internet Information Services, abbreviated IIS, Internet Information Services)
【转】最小描述长度准则MDL(Minimun Description Length)
ss-4.2 多个eureka集群案例
4.如何避免缓存穿透、缓存击穿、缓存雪崩
Tag stack - stack monotonically preparatory knowledge - lt. 739. The daily temperature