题目传送门:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1244
这个题目,貌似和【51NOD_1239】欧拉函数之和基本一样?
#include<bits/stdc++.h> #define LL long long using namespace std; const int N = 5000000+9; const int MX = 5000000; int mu[N],cnt,pri[N]; bool vis[N]; unordered_map<LL,LL> M; inline int prework(){ mu[1] = 1; for (int i=2;i<=MX;i++) { if (!vis[i]) pri[++cnt] = i, mu[i] = -1; for (int j=1;j<=cnt && pri[j]*i<=MX;j++) { vis[i*pri[j]] = 1; if (i%pri[j]) mu[i*pri[j]] = -mu[i]; else break; } } for (int i=1;i<=MX;i++) mu[i] += mu[i-1]; } inline LL solve(LL w) { if (w <= MX) return mu[w]; else if (M[w]) return M[w]; else { LL ret = 1; for (LL i=2,tmp;i<=w;i=tmp+1) { tmp = w / (w / i); ret -= solve(w/tmp)*(tmp-i+1); } M[w] = ret; return ret; } } int main(){ prework(); LL a,b; cin>>a>>b; printf("%d\n",solve(b)-solve(a-1)); return 0; }
I like this weblog so much, bookmarked.
993530 422515I real glad to discover this internet web site on bing, just what I was searching for : D likewise saved to bookmarks . 209253
12658 211655Your writing style has been amazed me. Thanks, quite great article. 75863
958692 942870You ought to join in a contest for starters with the highest quality blogs online. I will recommend this page! 474520
812188 866521Its difficult to get knowledgeable individuals with this subject, but the truth is could be seen as do you know what you are referring to! Thanks 249013
459587 740102Im agitated all these post directories. It positive would be good to have every article directory that instantly accepts articles. 950536
947368 981104I actually enjoy reading on this site, it holds great articles . 210426
707560 998483Definitely pent topic matter, regards for entropy. 684974
294351 336661A extremely quite intriguing article! Ill try to track that continues here! Thank you. 192076
868343 943950This internet site is my breathing in, real amazing design and perfect content . 938777
839 351711baby strollers with high traction rollers ought to be a lot safer to use compared to those with plastic wheels- 460555
659464 878001Discovered this on MSN and Im pleased I did. Properly written write-up. 337532
531964 441350Extremely informative and great complex body part of articles , now thats user pleasant (:. 22559
88314 319142Some truly good and utilitarian information on this internet website , besides I believe the layout holds wonderful capabilities. 881655
I just could not leave your web site prior to suggesting that I really enjoyed the usual information a person provide to your guests? Is going to be back incessantly in order to inspect new posts