Quick power modulo POJ 3761 bubble sort

Source: Internet
Author: User

Topic Portal

1 /*2 Test instructions: To find the number of full permutations of the bubble sort scan K-Times3 Mathematics: Here is the concept of an anti-sequence table, BJ is represented on the left of J, but is greater than the number of J. Not much to say, I also look at the online problem-solving report. 4 Detailed Explanation:http://blog.csdn.net/cscj2010/article/details/78209065 */6#include <cstdio>7#include <algorithm>8#include <cstring>9#include <cmath>Ten using namespacestd; One  AtypedefLong Longll; - Const intMAXN = 1e6 +Ten; - Const intINF =0x3f3f3f3f; the Const intMOD =20100713; - ll FACT[MAXN]; -  - voidSolvevoid)    { +fact[0] = fact[1] =1; -      for(intI=2; i<=1000000; ++i) { +Fact[i] = fact[i-1] * I%MOD; A     } at } -  - ll Pow_mod (ll X, ll N) { -LL ret =1; -      while(n) { -         if(N &1) ret = ret * x%MOD; inx = x * x%MOD; -N >>=1; to     } +     returnret; - } the  * intMainvoid)  {//POJ 3761 Bubble Sort $ solve ();Panax Notoginseng     intT scanf ("%d", &T); -      while(t--) { thell N, K; scanf ("%i64d%i64d", &n, &k); +printf ("%i64d\n", (Pow_mod (k +1, N-k)-Pow_mod (k, n-k) + MoD)% mod * Fact[k]%MOD); A     } the  +     return 0; -}

Quick power modulo POJ 3761 bubble sort

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.