문제 [51nod1225] 떨어져와의 수에 솔루션
얼굴 질문
해결
우선 발견 될 수 \ (A \) % \ (B \) \ (AB 및 * = \ lfloor A / B \ rfloor \) .
연속 들어 \ (B \) 이다 (\ lfloor A / B \ \ rfloor \) 와 동일하다.
그리고이 단락 \ (b는 \) 연산 시퀀스이다.
따라서 나누어 블록 라인에 실제로 결합.
데이터가 정말 역겨운 범위 (버스트 LONGLONG)
암호:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define int __int128
#define fre(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
using namespace std;
inline int read(){
int sum=0,f=1;char ch=getchar();
while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
return f*sum;
}
const int Mod=1000000007;
int n,ans;
inline int fpow(int a,int b){
int ret=1;
for(;b;a=a*a%Mod,b>>=1) if(b&1) ret=ret*a%Mod;
return ret;
}
signed main(){
n=read();int inv=fpow(2,Mod-2);
for(int l=1,r;l<=n;l=r+1){
r=n/(n/l);
ans=(ans+(n/l)*inv%Mod*(l+r)%Mod*(r-l+1)%Mod)%Mod;
}
ans=((n%Mod)*(n%Mod)-ans)%Mod;
long long ret=(ans+Mod)%Mod;
printf("%lld\n",ret);
return 0;
}