2016 multi-school sixth 1001-1003 (hdu5793&hdu5794&hdu5795)

Source: Internet
Author: User
Tags cas

This game to make a question, how can have nest so spicy chicken of person?

1001

Very complex formula, playing table to find the law, and finally M^0+m^1+...+m^n, the puzzle is directly (m^ (n+1)-1)/(m-1), long posture, the original can be reduced ... Do not write the problem.

1002

A chessboard, moves posture to meet (X1-X2) ^2+ (y1-y2) ^2==5, that is, the word "Day" walk, and can only go down to the right.

Some of these obstacles can not be passed, note that the barrier may be at the end point, the number of paths from (n,m) to the path.

Tolerance + combination number of the simple version of the cf559c (yes, I did this, I still did not do it, WA 10 times, La La La)

Over is to prevent the focus, feeling will not have the focus, but the game is really no =_=#

#include <cstdio> #include <cstring> #include <vector> #include <algorithm> #include < Iostream>using namespace Std;typedef Long Long ll;const ll MOD = 110119;const int max_p = 2000005;    ll Powmod (ll A, ll B, ll MoD) {ll res = 1;        while (b) {if (b & 1) res = res * a% mod;        A = a * a% mod;    b >>= 1; } return res;    ll fac[max_p];void Getfact () {fac[0] = 1; for (int i = 1; I <= 2000000; ++i) fac[i] = fac[i-1] * i% MOD;}    ll Lucas (ll N, ll M, ll P) {ll res = 1;        while (n && m) {ll a = n p;        ll b = m% p;        if (a < b) return 0;        res = res * Fac[a]% P * POWMOD (fac[b] * fac[a-b]% P, p-2, p)% p;        n/= p;    M/= p; } return res;    struct Point {ll x, y; Point (ll X, ll y): X (x), Y (y) {} point () {} bool operator< (const point A) const {if (x = = a.x) return y &l T        A.Y;    return x < a.x; } bool operator== (const POINT a) const {if (x = = a.x && y = = a.y) return true;    return false; }} p[2005];ll cal (Point A, point B) {ll dx = b.x-a.x;ll dy = b.y-a.y;ll R, c;if ((dx*2-dy)%3 | |  (DY*2-DX)%3) return 0;LL INV = Powmod (3, MOD-2, MOD); r = (2 * dx-dy)/3;c = (2 * dy-dx)/3;if (R < 0 | | C < 0) return 0;if (c = = 0 | | r = = 0) return 1;return Lucas (R+c, R, MOD);}    ll Ans[2005];bool Over[2005];int Main () {//freopen ("in", "R", stdin);    ll m, N, R;    Getfact ();    int cas = 0;        while (Cin >> m >> N >> R) {printf ("Case #%d:", ++cas);        Point S (1, 1);        for (int i = 0; i < R; ++i) scanf ("%lld%lld", &p[i].x, &AMP;P[I].Y);        p[r].x = m, p[r].y = n;        Sort (p, p + R);        if (p[r-1].x = = m && P[r-1].y = = N) {printf ("0\n");        Continue        } memset (over, false, sizeof over);        for (int i = 1; i < R; ++i) {if (p[i] = = P[i-1]) over[i] = true; } for (int i = 0;I <= R;            ++i) {if (over[i]) continue;            Ans[i] = cal (S, P[i]);                for (int j = 0; J < i; ++j) {if (over[j]) continue; if (p[j].x < p[i].x && P[j].y < P[I].Y) {Ans[i] = ((Ans[i]-Cal (P[j], p[i]) * Ans[j]%                MoD)% mod + MoD)% MoD;        }}} Ans[r] = (Ans[r] + mod)% MoD;    printf ("%lld\n", Ans[r]); } return 0;}

  

1003

The deformation of Nim game

There are n heaps of sugar, one at a time to take a bunch of any, or to divide a pile into three piles.

To a bunch of the value of the SG function, and then hit the table to find the law, it is not difficult, but did not want to understand, then there is a netizen reminded me (although the game is not so good ...). ), finally began to write, in fact, I was blind at first, write suddenly clear, but the wrong number ... sg[2] should be 2, I have written 0, mom Egg t^t

#include <cstdio> #include <cstring> #include <vector> #include <algorithm> #include < iostream>using namespace std; #define PF (x) cout << "Debug:" << x << ""; #define EL cout << End  l; #define PC (x) puts (x); typedef long LONG ll;const int N = 1000005;const int MOD = 1e9+7;int a[n];int sg[n];int get_sg (int    x) {if (x = = 0) return 0;    if (x = = 1) return 1;    if (x = = 2) return 2;    if (sg[x]! =-1) return sg[x];    int mex[200000] = {0};            for (int i = 1, i < x; ++i) {for (int j = i; j < x-i; ++j) {int k = x-i-J;            if (k <= 0) break;            int tmp = GET_SG (i) ^ Get_sg (j) ^ Get_sg (k);        MEX[TMP] = 1;    }} for (int i = 0; i < x; ++i) {Mex[get_sg (i)] = 1;    } for (int i = 0;; i++) {if (!mex[i]) return sg[x] = i;    }}int Main (int argc, char const *argv[]) {//memset (SG,-1, sizeof SG); for (int i = 0; i < ++i) {//cout << i << "" << get_sg (i) << Endl;    }//freopen ("In", "R", stdin);    int T;    scanf ("%d", &t);        while (t--) {int n;        scanf ("%d", &n);        int ans = 0;            for (int i = 0; i < n; ++i) {scanf ("%d", a+i);            If (A[i]% 8 = = 0) a[i]--;            else if (A[i]% 8 = = 7) a[i]++;        Ans ^= a[i]; } printf ("%s\n", ans?)    "First player wins.": "Second player wins."); } return 0;}

  

How can there be a person with such a weak nest?

2016 multi-school sixth 1001-1003 (hdu5793&hdu5794&hdu5795)

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.