Test instructions
Use x large m to divide a plane into several blocks.
is the enhanced version of the polyline cut plane.
A simple recursive formula: F (x+1) = 16x+1+f (x)
Then turn it into a pass-through formula, and then C + + bit-press the large number simulation
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm>using namespace Std;typedef long long ll;const int mod = 100000;struct node {int v[10]; Node () {memset (V, 0, sizeof v); V[0] = 1; } void Out () {printf ("%d", v[v[0]]); for (int i = v[0]-1; I >= 1;-i) printf ("%05d", V[i]); Putchar (' \ n '); }};char ch;void Get (ll& x) {while (ch = getchar ()) < ' 0 ' | | ch > ' 9 '); x = ch-' 0 '; while (ch = getchar ()) >= ' 0 ' && ch <= ' 9 ') x = x * + ch-' 0 ';} void Add (node& I, ll x) {int mx = 0; while (x > 0) {+ + mx; x = x + i.v[mx]; I.V[MX] = x% mod; x/= mod; } if (mx > i.v[0]) i.v[0] = mx;} void multi (node& A, ll x) {ll y = 0; for (int i = 1; I <= a.v[0]; ++i) {y = a.v[i] * x + y; A.v[i] = y% mod; Y/= mod; } int mx = a.v[0]; while (Y > 0) { + + mx; A.V[MX] = y% mod; Y/= mod; } a.v[0] = mx;} Node Cal (ll N) {node re; if (n = = 1) {re.v[1] = 2; } else {Add (RE, n * 8); multi (Re, n-1); Add (Re, n + 1); } return re;} int main () {node one; ONE.V[1] = 1; int T = 0, CAS; ll N; Node ans; scanf ("%d", &cas); while (CAS--> 0) {get (n); Ans = Cal (n); printf ("Case #%d:", ++t); Ans.out (); } return 0;}
HDU 5047 Sawtooth Law + C + + large number simulation ACM/ICPC Asia regional Shanghai Online