http://acm.hdu.edu.cn/showproblem.php?pid=5139
Idea: This problem must first find the law, f (N) =n!* (n-1)!* (n-2)!..... 1!; Can not directly hit the table, but offline processing, disposable processing out.
1#include <cstdio>2#include <cstring>3#include <map>4#include <algorithm>5 #definell Long Long6 #defineMoD 10000000077 #defineN 1000108 using namespacestd;9 Ten ll N; One structnode A { - ll C,id,m; - BOOL operator< (ConstNode &a)Const the { - returnid<a.id; - } - }p[n]; + BOOLCMP1 (node A,node b) - { + returna.c<B.C; A } at - intMain () - { - intt1=0; - while(SCANF ("%lld", &n)! =EOF) - { inP[t1].c=N; -P[t1].id=T1; tot1++; + } -Sort (p,p+t1,cmp1); thell s=1; *ll ans=1; $ intCnt=0;Panax Notoginseng for(intx=1; X<=p[t1-1].C; X + +) - { thes=s*x%MoD; +ans=ans*s%MoD; A while(cnt<t1&&p[cnt].c==x) the { +p[cnt].m=ans; -cnt++; $ } $ } -Sort (p,p+t1); - for(intI=0; i<t1; i++) the { -printf"%lld\n", P[I].M);Wuyi } the return 0; -}View Code
HDU 5139 Formula