CF1423K.Lonely Numbers

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In number world, two different numbers are friends if they have a lot in common, but also each one has unique perks.

More precisely, two different numbers aa and bb are friends if gcd(a,b)gcd(a,b) , agcd(a,b)\frac{a}{gcd(a,b)} , bgcd(a,b)\frac{b}{gcd(a,b)} can form sides of a triangle.

Three numbers aa , bb and cc can form sides of a triangle if a+b>ca + b > c , b+c>ab + c > a and c+a>bc + a > b .

In a group of numbers, a number is lonely if it doesn't have any friends in that group.

Given a group of numbers containing all numbers from 1,2,3,...,n1, 2, 3, ..., n , how many numbers in that group are lonely?

输入格式

The first line contains a single integer tt (1t106)(1 \leq t \leq 10^6) - number of test cases.

On next line there are tt numbers, nin_i (1ni106)(1 \leq n_i \leq 10^6) - meaning that in case ii you should solve for numbers 1,2,3,...,ni1, 2, 3, ..., n_i .

输出格式

For each test case, print the answer on separate lines: number of lonely numbers in group 1,2,3,...,ni1, 2, 3, ..., n_i .

输入输出样例

  • 输入#1

    3
    1 5 10

    输出#1

    1
    3
    3

说明/提示

For first test case, 11 is the only number and therefore lonely.

For second test case where n=5n=5 , numbers 11 , 33 and 55 are lonely.

For third test case where n=10n=10 , numbers 11 , 55 and 77 are lonely.

首页