HDU-1215-七夕节
http://acm.hdu.edu.cn/showproblem.php?pid=1215
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int a[500001];
void init()
{
int i,j;
memset(a,0,sizeof(a));
for(i=1;i<=500000;i++)
a[i]=1;
for(i=2;i<=250000;i++)
for(j=2;i*j<=500000;j++)
a[i*j]+=i;
}
int main()
{
int t,n;
init();
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
printf("%d\n",a[n]);
}
return 0;
}
HDU-1286-找新朋友
http://acm.hdu.edu.cn/showproblem.php?pid=1286
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int a[40000];
int main()
{
int i,j,t,n,ans;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
memset(a,0,sizeof(a));
for(i=2;i<=n;i++)
if(n%i==0)
{
for(j=2;j<=n;j+=i)
a[j]=1;
}
ans=0;
for(i=2;i<=n;i++)
if(a[i]==0)
ans++;
printf("%d\n",ans+1);
}
return 0;
}
HDU-1999-不可摸数
http://acm.hdu.edu.cn/showproblem.php?pid=1999
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int a[1000001],b[1001];
void init()
{
int i,j;
for(i=1;i<=500000;i++)
for(j=2;i*j<=1000000;j++)
a[i*j]+=i;
for(i=2;i<=1000000;i++)
if(a[i]<=1000)
b[a[i]]=1;
}
int main()
{
int t,n;
init();
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
if(b[n]==1)
printf("no\n");
else
printf("yes\n");
}
return 0;
}
分享到:
相关推荐
使用筛选法来确定100以内的素数并将其输出 使用时请在dev运行
筛选法求素数,在大范围内求素数比其他方法高效很多。
GJB1032电子产品环境应力筛选方法.pdf
以C++为编程语言,筛选法,编写的求一个数以内的素数
GJB1032电子产品环境应力筛选方法; 环境试验、环境筛选,可靠性相关;
Eratosthenes筛选法求质数.rar
2020年维亚生物专题研究:SBDD和FBDD成为有望替代高通量筛选的新型主流筛选方法
用筛选法筛选出输入的两个数之间的素数比且把他显示在屏幕上。
一个接触即会的c语言筛选方法 方法新颖独特
间歇信号的经验模态筛选方法,钱昌松,刘代志,本文聚焦于如何解决经验模态分解中由间歇事件引起的模态混叠问题,提出描述间歇事件的间歇经验模态分量(Intermittent Empirical Mode Funct
行业资料-电子功用-基于相关性分析的火电厂过程稳态建模变量筛选方法
20210721-国泰君安-学界纵横系列之十六:基于随机贴现模型的因子筛选法.pdf
网络游戏-一种基于复杂网络社区发现的工业数据样本筛选方法.zip
筛选法是从另外的角度选择,可以更快的得到结果
采用筛选法和插入法进行堆排序 oid HeapSort(int r[],int n) { int i,j; for(j=n;j>=1;j--) { for(i=j/2;i>0;i--) SiftHeap(r,i,j); r[0]=r[1];r[1]=r[j];r[j]=r[0]; }
【题目描述】 用筛法求出n(2≤n≤1000)以内的全部质数。 【输入】 输入n。 【输出】 多行,由小到大的质数。 【输入样例】 10 【输出样例】 2 3 5 7
易语言Eratosthenes筛选法求质数源码,Eratosthenes筛选法求质数,Eratosthenes筛选法_求质数
专题资料
电解电容器的筛选方法doc,电解电容器的筛选方法