ZOJ 3286 Very Simple Counting
来源:互联网 发布:淘宝店食品经营许可证 编辑:程序博客网 时间:2024/05/21 14:45
Very Simple Counting
Time Limit: 1 Second Memory Limit: 32768 KB
Let f(n) be the number of factors of integer n.
Your task is to count the number of i(1 <= i < n) that makes f(i) = f(n).
Input
One n per line (1 < n <= 1000000).
There are 10000 lines at most.
Output
For each n, output counting result in one line.
Sample Input
45
Sample Output
02
Hint
f(1) = 1, f(2) = f(3) = f(5) = 2, f(4) = 3.
#include<stdio.h>
int prime[1000005]={0};
int sum[1000005]={0};
int p[1000005]={0};
void prim()
{
prime[1]=prime[0]=1;
for(int i=1;i<=500000;++i) prime[i<<1]=2;
for(int i=3;i<=1000;++i)
if(prime[i]==0)
{
prime[i]=i;
int k=i*i;
while(k<1000000)
{
if(prime[k]==0) prime[k]=i;
k+=i;
}
}
for(int i=2;i<=1000000;++i)
if(prime[i]==0) prime[i]=i;
}
int main()
{
prim();
sum[1]++;p[1]=0;
for(int i=2;i<=1000000;i++)
if(prime[i]==i)
{
sum[2]++;
p[i]=sum[2]-1;
}
else
{
int ans=1;
int t=i;
while(t>1)
{
int k=prime[t];
int count=1;
while(t%k==0)
{
t=t/k;
count++;
}
ans=ans*count;
}
sum[ans]++;
p[i]=sum[ans]-1;;
}
int n;
while(scanf("%d",&n)!=EOF)
{
printf("%d/n",p[n]);
}
return 0;
}
- ZOJ 3286 Very Simple Counting
- ZOJ:3286 Very Simple Counting
- ZOJ Very Simple Counting
- ZOJ 3286 Very Simple Counting(打表)
- 1166 Very Simple Problem
- [Java]Very simple problem
- sgu111:Very simple problem
- 111. Very simple problem
- SGU111 Very simple problem
- Very simple A* algorithm implementation
- FOJ 1350 Very Simple Problem
- FZU 1350 Very Simple Problem
- POJ 2535 Very Simple Problem
- A very simple CTransInPlaceFilter example
- SGU 111 Very simple problem
- [SGU]111. Very simple problem
- SGU 111 Very simple problem
- poj 2535 Very Simple Problem
- 拼接SQL查询结果字符串输出
- 重载(overload),覆盖(override),隐藏(hide)
- 《web数据挖掘》
- 什么是OOA/OOD
- 将iPhone破解的app或者自己开发的app格式安装包打包为ipa格式安装包
- ZOJ 3286 Very Simple Counting
- 内存对齐
- PHP下载或导出文件时的若干问题
- avr单片机 串口实现printf(使用变参函数)
- ce
- 微调按钮
- jsp页面自动定时跳转返回代码
- Android 程序的安装、卸载和更新
- LPT COM RS232 RS232C 并口 串口