Full score refers to the number of score factors. Calculate the number of non-complete records of the ki number.
Solution: an obvious binary algorithm. getsum (int middle) is used to calculate the number of non-full partitions in 1-middle, and then a binary algorithm. 1. Calculate the number of non-full partitions of the middle and then subtract the number of full partitions from the total number. Describe the total number of shards:
First add n/(2*2) + n/(3*3) + n/(5*5) + n/(7*7 )... +... then, subtract the one that appears twice, and add the following three times... odd addition and even subtraction. This is the prototype of mou, which is easy to calculate using the mou array;
Code:
/******************************************************* @author:xiefubao*******************************************************/#pragma comment(linker, "/STACK:102400000,102400000")#include
#include
#include
#include
#include
#include
#include #include
#include
#include
#include
#include
//freopen ("in.txt" , "r" , stdin);using namespace std;#define eps 1e-8#define zero(_) (abs(_)<=eps)const double pi=acos(-1.0);typedef unsigned long long LL;const int Max=100010;const LL INF=2e16+7;LL mou[Max];void init(){ for(LL i=2; i
>t; while(t--) { scanf("%d",&k); LL left=1,right=INF; while(left<=right) { int middle=(left+right)/2; if(getnum(middle)