Title Link: http://acm.split.hdu.edu.cn/showproblem.php?pid=1452
Test instructions: To find all the factors and 2004^n.
1#include <algorithm>2#include <iostream>3#include <iomanip>4#include <cstring>5#include <climits>6#include <complex>7#include <fstream>8#include <cassert>9#include <cstdio>Ten#include <bitset> One#include <vector> A#include <deque> -#include <queue> -#include <stack> the#include <ctime> -#include <Set> -#include <map> -#include <cmath> + using namespacestd; - #defineFr First + #defineSC Second A #defineCL Clear at #defineBUG puts ("Here!!!") - #defineW (a) while (a--) - #definePB (a) push_back (a) - #defineRint (a) scanf ("%d", &a) - #defineRll (a) scanf ("%i64d", &a) - #defineRs (a) scanf ("%s", a) in #defineCIN (a) CIN >> a - #defineFRead () freopen ("in", "R", stdin) to #defineFWrite () freopen ("Out", "w", stdout) + #defineRep (i, Len) for (int i = 0; i < (len); i++) - #defineFor (I, A, Len) for (int i = (a); I < (len); i++) the #defineCls (a) memset ((a), 0, sizeof (a)) * #defineCLR (A, X) memset ((a), (x), sizeof (a)) $ #defineFull (a) memset ((a), 0x7f7f7f, sizeof (a))Panax Notoginseng #defineLRT RT << 1 - #defineRRT RT << 1 | 1 the #definePi 3.14159265359 + #defineRT return A #defineLowbit (x) x & (-X) the #defineONECNT (x) __builtin_popcount (x) +typedefLong LongLL; -typedefLong DoubleLD; $typedef unsignedLong LongULL; $typedef pair<int,int>PII; -typedef pair<string,int>psi; -typedef pair<int,int>PLL; thetypedef map<string,int>MSI; -typedef vector<int>VI;Wuyitypedef vector<int>VL; thetypedef vector<vl>VVL; -typedef vector<BOOL>vb; Wu - ConstLL mod = in; About LL N; $ - ll Mul (ll X, ll Q) { -LL ret =1; - while(q) { A if(Q &1) ret = (ret * x)%MoD; +Q >>=1; thex = (x * x)%MoD; - } $ returnret; the } the thell EXGCD (ll A, ll B, ll &x, LL &y) { the if(b = =0) { -x =1; iny =0; the returnA; the } About Else { theLL ret = EXGCD (b, a%b, x, y); theLL tmp =x; thex =y; +y = tmp-a/b *y; - returnret; the }Bayi } the the LL IV (ll a) { - LL x, y; - exgcd (A, mod, x, y); the return(x% mod + MoD)%MoD; the } the the signed Main () { - //FRead (); the while(Cin >> N &&N) { thecout << ((Mul (2,2*n+1)-1)%mod) * ((Mul (3, n+1)-1) *iv (2)%mod) * ((Mul (167, n+1)-1) *iv (166)%mod)%mod <<Endl; the }94Rt0; the}
[HDOJ1492] Happy 2004 (number theory, fast power, inverse, integrable function)