Bi-shoe and Phi-shoe Bamboo Pole-vault is a massively popular sport in Xzhiland. And Master Phi-shoe is a very popular coach for his success. He needs some bamboos for his students, so he asked his assistant Bi-Shoe to go to the market and buy them.…
题目描述 求 输入 第一行包含一个正整数T,表示有T组测试数据.接下来T<=10^5行,每行给出一个正整数N,N<=10^6. 输出 包含T行,依次给出对应的答案. 样例输入 7 1 10 100 1000 10000 100000 1000000 样例输出 1 2127 18446224 183011304660 1827127167830060 18269345553999897648 182690854273058293758232 题解 “高精度”+欧拉函数+线性筛 由于$i$和$j$…
2818: Gcd Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 3241  Solved: 1437[Submit][Status][Discuss] Description 给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对. Input 一个整数N Output 如题 Sample Input 4 Sample Output 4 HINT hint 对于样例(2,2),(2,4),(3,3),(4,2) 1&…
向大(hei)佬(e)势力学(di)习(tou) Description 作为体育委员,C君负责这次运动会仪仗队的训练.仪仗队是由学生组成的N * N的方阵,为了保证队伍在行进中整齐划一,C君会跟在仪仗队的左后方,根据其视线所及的学生人数来判断队伍是否整齐(如下图). 现在,C君希望你告诉他队伍整齐时能看到的学生人数. Input 共一个数N. Output 共一个数,即C君应看到的学生人数. Sample Input 4 Sample Output 9 HINT [数据规模和约定] 对于 10…
The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few are F2 = {1/2} F3 = {1/3, 1/2, 2/3} F4 = {1/4, 1/3, 1/2, 2/3, 3…
这题有两种解法,1是根据欧拉函数性质:素数的欧拉函数值=素数-1(可根据欧拉定义看出)欧拉函数定义:小于x且与x互质的数的个数 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iom…
一通套路后得Σφ(d)μ(D/d)⌊n/D⌋2.显然整除分块,问题在于怎么快速计算φ和μ的狄利克雷卷积.积性函数的卷积还是积性函数,那么线性筛即可.因为μ(pc)=0 (c>=2),所以f(pc)还是比较好算的,讨论一波即可. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorith…
[BZOJ2401]陶陶的难题I 题意:求,n<=1000000,T<=100000 题解:直接做是n*sqrt(n)的,显然会TLE,不过这题a和b都是循环到n,那么就可以进行如下的神奇变换: $\sum\limits_{i=1}^n\sum\limits_{j=1}^nlcm(i,j)=2*\sum\limits_{i=1}^n\sum\limits_{j=1}^ilcm(i,j)-\sum\limits_{i=1}^ni$ 是不是很神奇?然后继续推即可. 设$f(i)=\sum\limi…
HDU6434 I. Count T次询问,每次询问\(\sum_{i=1}^{n}\sum_{j=1}^{n-1}[gcd(i-j,i+j)=1]\) \(T\le 1e5, n \le 2e7\) 对原式进行转换,枚举\(i-j\) ,\(i-j\)为\(j\) ,那么可以变换为\(\sum_{i=1}^{n}\sum_{j=1}^{i-1}[gcd(j,2i-j)=1]\) \(\Rightarrow \sum_{i=1}^{n}\sum_{j=1}^{i-1}[gcd(j,2i)=1]\…
基础题. PS:注意unsigned long long; 以及%llu #include<bits/stdc++.h> using namespace std; typedef unsigned long long ULL; typedef long long LL; const int N=5e6+10; bool isprime[N]; ULL res[N]; void init() { res[1]=1ULL; for(LL i=1;i<=5000000;i++) { ispri…