[bzoj4591] [Shoi2015] super-energy particle cannon • change

Source: Internet
Author: User

Formula phobia patient membrane a half-day Qaq

The specific process see the other online bar >_<

1#include <cstdio>2#include <iostream>3#include <cstring>4#include <algorithm>5 #definell Long Long6 #defineMOD (x) x-=x>=modd?modd:07 using namespacestd;8 Const intModd=2333;9 intc[modd][modd],sum[modd][modd];Ten ll N,k; One   A   -   -InlineintLucas (ll A,ll b) { the     if(A&LT;B)return 0; -     if(a<modd&&b<modd)returnC[a][b]; -     returnC[a%modd][b%modd]*lucas (a/modd,b/modd)%modd; - } + intCalc (ll n,ll k) { -     if(k<0)return 0; +     return(Calc (n/modd,k/modd-1) *sum[n%modd][2332]+lucas (n/modd,k/modd) *sum[n%modd][k%modd])%modd; A } atInlinevoidPrerun () { -Registerinti,j; -      for(i=0; i<modd;i++) c[i][0]=sum[i][0]=sum[0][i]=1; -      for(i=1; i<modd;i++) -          for(j=1; j<=i;j++) -c[i][j]=c[i-1][j]+c[i-1][j-1],mod (C[i][j]), insum[i][j]=sum[i][j-1]+C[i][j],mod (Sum[i][j]); -      for(i=1; i<modd;i++) for(j=i+1; j<modd;j++) sum[i][j]=sum[i][j-1]; to } + intMain () { -Prerun ();intT; the      for(SCANF ("%d", &t); T t--) *scanf"%lld%lld", &n,&k), printf ("%d\n", Calc (n,k)); $ }Panax Notoginseng 
View Code

[bzoj4591] [Shoi2015] super-capable particle cannon/change

Related Article

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.