牛客网暑期ACM多校训练营(第三场)H Diff-prime Pairs (贡献)

链接:https://ac.nowcoder.com/acm/contest/141/H来源:牛客网

Eddy has solved lots of problem involving calculating the number of coprime pairs within some range. This problem can be solved with inclusion-exclusion method. Eddy has implemented it lots of times. Someday, when he encounters another coprime pairs problem, he comes up with diff-prime pairs problem. diff-prime pairs problem is that given N, you need to find the number of pairs (i, j), where igcd(i,j)\frac{i}{gcd(i, j)}gcd(i,j)i and jgcd(i,j)\frac{j}{gcd(i,j)}gcd(i,j)j are both prime and i ,j ≤ N. gcd(i, j) is the greatest common divisor of i and j. Prime is an integer greater than 1 and has only 2 positive divisors.

Eddy tried to solve it with inclusion-exclusion method but failed. Please help Eddy to solve this problem.

Note that pair (i1, j1) and pair (i2, j2) are considered different if i1 ≠ i2 or j1 ≠ j2.

输入描述:

Input has only one line containing a positive integer N.1 ≤ N ≤ 107

输出描述:

Output one line containing a non-negative integer indicating the number of diff-prime pairs (i,j) where i, j ≤ N

示例1

输入

[复制](javascript:void(0)

牛客网暑期ACM多校训练营(第三场)H Diff-prime Pairs (贡献)的更多相关文章

  1. 牛客网 暑期ACM多校训练营(第二场)A.run-动态规划 or 递推?

    牛客网暑期ACM多校训练营(第二场) 水博客. A.run 题意就是一个人一秒可以走1步或者跑K步,不能连续跑2秒,他从0开始移动,移动到[L,R]的某一点就可以结束.问一共有多少种移动的方式. 个人 ...

  2. 牛客网 暑期ACM多校训练营(第一场)A.Monotonic Matrix-矩阵转化为格子路径的非降路径计数,Lindström-Gessel-Viennot引理-组合数学

    牛客网暑期ACM多校训练营(第一场) A.Monotonic Matrix 这个题就是给你一个n*m的矩阵,往里面填{0,1,2}这三种数,要求是Ai,j⩽Ai+1,j,Ai,j⩽Ai,j+1 ,问你 ...

  3. 2018牛客网暑期ACM多校训练营(第二场)I- car ( 思维)

    2018牛客网暑期ACM多校训练营(第二场)I- car 链接:https://ac.nowcoder.com/acm/contest/140/I来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 ...

  4. 牛客网暑期ACM多校训练营(第一场) - J Different Integers(线段数组or莫队)

    链接:https://www.nowcoder.com/acm/contest/139/J来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048 ...

  5. 牛客网暑期ACM多校训练营(第九场) A题 FWT

    链接:https://www.nowcoder.com/acm/contest/147/A来源:牛客网 Niuniu has recently learned how to use Gaussian ...

  6. 牛客网暑期ACM多校训练营(第九场)D

    链接:https://www.nowcoder.com/acm/contest/147/D来源:牛客网 Niuniu likes traveling. Now he will travel on a ...

  7. 牛客网暑期ACM多校训练营(第二场)B discount

    链接:https://www.nowcoder.com/acm/contest/140/B来源:牛客网 题目描述 White Rabbit wants to buy some drinks from ...

  8. 2018牛客网暑期ACM多校训练营(第一场)D图同构,J

    链接:https://www.nowcoder.com/acm/contest/139/D来源:牛客网 同构图:假设G=(V,E)和G1=(V1,E1)是两个图,如果存在一个双射m:V→V1,使得对所 ...

  9. 牛客网暑期ACM多校训练营(第二场) I Car 思维

    链接:https://www.nowcoder.com/acm/contest/140/I来源:牛客网 White Cloud has a square of n*n from (1,1) to (n ...

  10. 牛客网暑期ACM多校训练营(第二场) D money 思维

    链接:https://www.nowcoder.com/acm/contest/140/D来源:牛客网 White Cloud has built n stores numbered from 1 t ...

随机推荐

  1. node及npm安装与配置

    一,安装环境查看 软件版本选择 node 10.16.3 二,软件安装 软件下载,下载地址 https://nodejs.org/dist/ 解压安装 cp node-v10.16.3-linux-x ...

  2. Clean Code 代码检查清单

    注释: 不恰当的信息:注释只应该描述有关代码和设计的技术性信息. 废弃的注释:过时.无关或不正确的注释就是废弃的注释. 冗余注释:注释应该谈及代码自身没提到的东西 糟糕的注释:值得编写的注释,也值得好 ...

  3. linux定时任务每隔5分钟向文本追加一行

    编写shell脚本 test.sh内容如下,上传到linux的root目录 更改文件权限 chmod  777   test.sh 编辑定时任务 crontab  -e */5    *  *  *  ...

  4. 022 Android .9图片的含义及制作教程

    1.图片(.9.png格式)的概念 (1)9patch图片是andriod app开发里一种特殊的图片形式,文件的扩展名为:.9.png (2)9patch图片的作用就是在图片拉伸的时候保证其不会失真 ...

  5. 循环(数组循环、获取json数据循环)、each()循环详解

    return; // 退出循环(不满足,退出此次循环.下次满足条件,依然会走此循环)return false; //退出函数(退出所有) 一. 数组循环: html: <div class=&q ...

  6. Web服务器和Tomcat

    Web服务器常用: WebLogic:是BEA公司的推出的产品,现在已经被oracle收购,是目前应用最广泛的Web服务器,支持JavaEE规范,商用收费,开发者可以免费使用. WebSphere:I ...

  7. python学习-52 XML模块

    XML模块 xml是实现不同语言或程序之间进行数据交换的协议,跟json差不多,但是json使用起来更简单. 例如:创建一个xml文件 <data> <country name=&q ...

  8. Python——多态、检查类型

    一.多态 Python变量并不需要声明类型,同一个变量可以在不同的时间引用不同的对象,当一个变量在调用同一个方法,可以呈现出多种行为,而具体呈现出哪种行为由该变量引用的对象来决定,这就是多态. 先看一 ...

  9. Python入门学习——PyQt5程序基本结构

    在学习python GUI部分时,一开始看书有点懵,看不懂框架,以下是个人学习所得(参考了别人的视频讲解),错误之处,望大家指教 #0.导入需要的包和模块from PyQt5.Qt import * ...

  10. Vue.js 2.x 混入

    Vue.js 2.x mixins 混入 混入(mixins)是一种分发vue组件中可复用功能的非常灵活的方式.混入对象可以包含任意组件选项.当组件使用混入对象时,所有混入对象的选项将被混入该组件本身 ...