bzoj:4407: Shinzhi Fury Enhanced Edition

Source: Internet
Author: User

Description to the next n,m,k.

Input has more than one set of data, the first line of input data two positive integer t,k, representing a T group of data, the meaning of K as shown above, the second line below to the t+1 line, each behavior two positive integer n,m, the meaning of the above-mentioned figure.

Output title

Sample Input1 2
3 3Sample Output -How does it feel to be a topic of water? mention a d^k at the back of Mo, and then put μ and d^k together, pre-treatment out on the good. but pay attention to the pre-processing when writing Nlogn notation will T, to be placed in the Linear sieve O (n) sieve out, 30+s. (Maya, what is 10+s?
#include <cstdio>#include<algorithm>#defineN 5000000using namespacestd;Const intmod=1e9+7;intt,n,m,k,k,num=0, p[n],mu[n+1],ne,f[n+1],mmh;BOOLbo[n+1];inlineintMintx) { while(X>=mod) X-=mod; while(x<0) X+=mod;returnx;} InlineintMiintAintx) {MMH=1;  while(x) {if(x&1) mmh=1ll*mmh*a%MOD; X>>=1; A=1ll*a*a%MOD; }    returnMmh;} InlineintMinintAintb) {returnA<b?a:b;}intMain () {registerinti,j,k,l; scanf ("%d%d",&t,&j); mu[1]=1; f[1]=1;  for(i=2; i<=n;i++){        if(!bo[i]) p[++num]=i,mu[i]=-1, F[i]=mi (i,k)-1;  for(j=1;j<=num&& (ne=p[j]*i) <=n;j++) {Bo[ne]=1; if(I%p[j]) mu[ne]=-mu[i],f[ne]=1ll*f[i]*f[p[j]]%mod;Else{Mu[ne]=0; F[ne]=1ll*f[i]*mi (p[j],k)%MOD;  Break; }        }    }     for(i=1; i<=n;i++) F[i]=m (f[i]+f[i-1]);  while(t--) {scanf ("%d%d",&n,&m); if(n>m) swap (N,M);  for(i=1, j=0, mmh=0; i<=n;j=i++) I=min (n/(n/i), m/(m/i)), Mmh=m (mmh+1ll* (n/i) * (m/i)%mod*m (F[i]-f[j])%MOD); printf ("%d\n", MMH); }}
64280 KB 31400 ms C++/edit 1092 B

bzoj:4407: Shinzhi Fury Enhanced Edition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.