min25

Posted 爷灬傲奈我何123

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了min25相关的知识,希望对你有一定的参考价值。

// Problem: #6053. 简单的函数
// Contest: LibreOJ
// URL: https://loj.ac/p/6053
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//#pragma GCC target("avx")
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast")
// created by myq 
//#pragma GCC target("avx")
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast")
// created by myq
#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cctype>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define x first
#define y second
typedef pair<int,int> pii;
const int N = 200010;
const int mod=1e9+7;
inline int read()
{
	int res=0;
	int f=1;
	char c=getchar();
	while(c>'9' ||c<'0')
	{
		if(c=='-')	f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		res=(res<<3)+(res<<1)+c-'0';
	}
	return res;
 }
#define int long long
int qmi(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)	res=res*a%mod;
		b>>=1;
		a=a*a%mod;	
	}
	return res;
}
int inv2=qmi(2,mod-2);
int n; 
bool st[N];
int g1[N];
int g2[N];
int cnt;
int prime[N];
int sum1[N];
int a[N]; 
int sum2[N];
int id1[N];
int T;
int m;
int id2[N];
inline int  id(int x)	
{
	return 	x<=T?id1[x]:id2[n/x];
}
int S(int x,int y)
{
//	cout<<x<<" "<<y<<endl;
	if(x<=1 || prime[y]>x )	return 0;
	int nowid=id(x);
	int res=((g1[nowid]-sum1[y-1]+sum2[y-1]-g2[nowid])%mod+mod)%mod;
	if(y==1)	res=(res+2)%mod;
	for(int i=y;i<=cnt&&prime[i]*prime[i]<=x;++i)
	{
		int t1=prime[i];
		int t2=prime[i]*prime[i];
//		if(prime[i]*prime[i]>x)
		
		for(int j=1;t2<=x;++j,t1=t2,t2*=prime[i])
		{
			res=(res+(prime[i]^j)*S(x/t1,i+1)%mod+(prime[i]^(j+1)))%mod;
		}
	}
	
		return res;
}
void init()
{
	 T=sqrt(n+0.5);
//	 prime[0]=1;
	for(int i=2;i<=T;i++)
	{
		if(!st[i])
		{
			prime[++cnt]=i;
			sum1[cnt]=sum1[cnt-1]+i;
			sum2[cnt]=sum2[cnt-1]+1;
		}
		for(int j=1;j<=cnt&&i*prime[j]<=T;j++)
		{
			st[i*prime[j]]=true;
			if(i%prime[j]==0)	break;
		}
	}

	for(int l=1;l<=n;l=n/(n/l)+1)
	{
		a[++m]=n/l;
		if(a[m]<=T)	id1[a[m]]=m;	
		else		id2[n/a[m]]=m;
		g1[m]=((a[m]%mod*(a[m]%mod+1)%mod*inv2%mod-1)%mod+mod)%mod;
		g2[m]=((a[m]-1)%mod+mod)%mod;
	}
	for(int j=1;j<=cnt;++j)
	{
		for(int i=1;i<=m && prime[j]*prime[j]<=a[i];++i)
		{
			g1[i]=((g1[i]-prime[j]*(g1[id(a[i]/prime[j])]-sum1[j-1]))%mod+mod)%mod;
			g2[i]=((g2[i]-1*(g2[id(a[i]/prime[j])]-sum2[j-1]))%mod+mod)%mod;
		}
	}
//	cout<<cnt<<endl;
}
signed main()
{
	cin>>n;
	init();
//	cout<<n<<endl;
	cout<<(S(n,1)+1)%mod<<endl;
	return 0;

}
/**
* In every life we have some trouble
* When you worry you make it double
* Don't worry,be happy.
**/




以上是关于min25的主要内容,如果未能解决你的问题,请参考以下文章

Min_25筛 学习小记

UOJ188. UR #13Sanrd [min_25筛]

片段 popbackstack 行为在 25.1.0 和 25.1.1 中被破坏

刷新片段不再起作用?

pbootcms对接微信扫码登录代码核心片段和步骤(前后端)

Python代码阅读(第25篇):将多行字符串拆分成列表