logo AlgoBeat OnlineJudge
登录 注册

#207833. 「CMOI R1」Bismuth / Linear Sieve

内存限制:128 MiB 时间限制:500 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Can you imagine find wakeless,like a satellite,in the black sky?

Somewhere,like a star.

We dream about things way beyond this atmosphere.

At we're now,on the air.

……

But I eventually evaporates in a blackhole…

Will I just stick up there?……


给定以下程序中的 (即输入),求以下伪代码的输出结果。

Input n
For i := 1 to n
	is_not_prime[i] := 0
cntp := 0
counter := 0
For i := 2 to n {
	If is_not_prime[i] = 0 {
		cntp := cntp + 1
		primes[cntp] := i
	}
	For j := 1 to cntp {
		If i * primes[j] > n
			break
		is_not_prime[i * primes[j]] := 1
		If i Mod primes[j] > 0 // should be `If i Mod primes[j] = 0` in Sieve of Euler
			break
		counter := counter + 1
	}
}
Print cntp, counter

请注意此代码不是线性筛,差别在注释过的那一行。

输入格式

一行一个整数,即输入,也就是给定的 。

输出格式

一行两个非负整数,即伪代码输出。

样例

样例输入 1

100

样例输出 1

50 30

样例输入 2

9876543

样例输出 2

4938272 3092277

样例输入 3

998877665544332211

样例输出 3

499438832772166106 312742219398875473

数据范围与提示

本题采用捆绑测试,并且存在子任务依赖(只有你拿到了一个子任务前一个子任务的分,你才有可能拿到该子任务的分)。

数据范围

约束条件 分值

对于 的数据,满足 。