QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#734897 | #9612. 月亮的背面是粉红色的 | 275307894a | 3 | 2322ms | 137816kb | C++14 | 2.5kb | 2024-11-11 15:44:31 | 2024-11-11 15:44:34 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e8+5,M=3.3e7+5,K=1000+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
ll n,k;int m;
bitset<N> flag;
char mu[N];
int pr[N/10],ph;
void init(){
mu[1]=1;
for(int i=2;i<=k;i++){
if(!flag[i]) pr[++ph]=i,mu[i]=-1;
for(int j=1;j<=ph&&i*pr[j]<=k;j++){
flag[i*pr[j]]=1;
if(i%pr[j]==0) break;
mu[i*pr[j]]=-mu[i];
}
}
}
using cp=complex<ll>;using LL=__int128;
cp pt;int lim;
ll tot1,tot2,ans1,ans2;
void calc(cp l,cp r,ll n){
// gdb(pt.real(),pt.imag());
if(pt.imag()<=lim) return;
cp mid=l+r;
cp p=pt+mid;
if(p.imag()>n/p.real()) calc(l,mid,n);
while(1){
p=pt+mid;
if(p.imag()>n/p.real()){
tot1+=(pt.real()+p.real()-1)*(-mid.imag()+1)/2-pt.real();
pt+=mid;
}else break;
}
if(LL(r.imag())*p.real()*p.real()>=-LL(n)*r.real()) calc(mid,r,n);
}
void Solve(){
scanf("%lld%d",&n,&m);
k=sqrtl(n);
init();
ll Ld=n+1;
for(int i=1;1ll*i*i<=n;i++)if(mu[i]){
ll d=n/i/i;
if(d^Ld){
Ld=d;int k=sqrtl(d);
tot1=0;lim=powl(d,1.0/3)*5;
pt=cp(d/k,k+1);calc(cp(0,-1),cp(1,0),d);
for(int i=1;i<pt.imag();i++) tot1+=d/i;
tot1=tot1*2-1ll*k*k;
if(m){
tot2=-(1ll*(k+1)*k/2%mod)*(1ll*(k+1)*k/2%mod);
for(int j=1;j<=k;j++){
ll k=d/j%mod;
tot2+=k*(k+1)%mod*j%mod;
}
}
tot1%=mod;tot2%=mod;
}
ans1+=tot1*mu[i];
if(m) ans2+=tot2*mu[i]*i%mod*i%mod;
}
ans1=(ans1%mod+mod)%mod;
if(m) ans2=(ans2%mod+mod)%mod;
printf("%lld ",ans1*ans1%mod);
if(m) printf("%lld\n",ans2*ans2%mod);
}
int main(){
int t=1;
// scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 3
Accepted
Test #1:
score: 3
Accepted
time: 1ms
memory: 6044kb
input:
1726 1
output:
84290761 74619067
result:
ok 2 number(s): "84290761 74619067"
Test #2:
score: 3
Accepted
time: 1ms
memory: 6160kb
input:
3608 1
output:
433014481 672891299
result:
ok 2 number(s): "433014481 672891299"
Test #3:
score: 3
Accepted
time: 1ms
memory: 6100kb
input:
2921 1
output:
271096225 547734266
result:
ok 2 number(s): "271096225 547734266"
Subtask #2:
score: 0
Wrong Answer
Test #4:
score: 0
Wrong Answer
time: 1ms
memory: 6080kb
input:
6116899 1
output:
460826951 301450440
result:
wrong answer 1st numbers differ - expected: '219318963', found: '460826951'
Subtask #3:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 3ms
memory: 6128kb
input:
6469467712 0
output:
833208603
result:
wrong answer 1st numbers differ - expected: '147393348', found: '833208603'
Subtask #4:
score: 0
Wrong Answer
Test #10:
score: 0
Wrong Answer
time: 6ms
memory: 6188kb
input:
8292948816 1
output:
542988704 287485757
result:
wrong answer 1st numbers differ - expected: '566765721', found: '542988704'
Subtask #5:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 53ms
memory: 6592kb
input:
900472451132 1
output:
354695266 963765719
result:
wrong answer 1st numbers differ - expected: '247050500', found: '354695266'
Subtask #6:
score: 0
Wrong Answer
Test #16:
score: 0
Wrong Answer
time: 173ms
memory: 13152kb
input:
9864907300784 1
output:
554080117 720268421
result:
wrong answer 1st numbers differ - expected: '359943536', found: '554080117'
Subtask #7:
score: 0
Wrong Answer
Test #19:
score: 0
Wrong Answer
time: 241ms
memory: 20456kb
input:
96735749745529 0
output:
554972961
result:
wrong answer 1st numbers differ - expected: '223354886', found: '554972961'
Subtask #8:
score: 0
Wrong Answer
Test #22:
score: 0
Wrong Answer
time: 546ms
memory: 20564kb
input:
94060593399194 1
output:
758488909 887133157
result:
wrong answer 1st numbers differ - expected: '52991150', found: '758488909'
Subtask #9:
score: 0
Wrong Answer
Test #25:
score: 0
Wrong Answer
time: 2322ms
memory: 137816kb
input:
9772457586483846 0
output:
801321788
result:
wrong answer 1st numbers differ - expected: '631039552', found: '801321788'
Subtask #10:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 1759ms
memory: 51968kb
input:
949243849085176 1
output:
598562417 771553755
result:
wrong answer 1st numbers differ - expected: '508465534', found: '598562417'