uva 1567,lga1567

來源:互聯網
上載者:User

uva 1567,lga1567

題目連結:uva 1567 - A simple stone game

題目大意:給定K和N,表示一堆石子有N個,先手第一次可以取1~N-1個石子,取到最後一個石子的人勝利,單詞每次操作時,取的石子數不能超過對手上一次取的石子數m的K倍。問先手是否可以必勝,可以輸出最小的首次操作。

解題思路:這題想了一天,又是打表找規律,又是推公式的,楞是做不出來,後來在網上找到了一篇題解,將的很清楚,解題寶典

/******************* * K倍動態減法遊戲 * 參考:http://www.cnblogs.com/jianglangcaijin/archive/2012/12/19/2825539.html*******************/#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 1e6+5;int N, K, a[maxn], b[maxn];int main () {    int cas;    scanf("%d", &cas);    for (int i = 1; i <= cas; i++) {        scanf("%d%d", &N, &K);        int p = 0, q = 0;        a[0] = b[0] = 0;        while (a[p] < N) {            a[p+1] = b[p] + 1;            p++;            while (a[q + 1] * K < a[p])                q++;            b[p] = b[q] + a[p];        }        printf("Case %d: ", i);        if (N == a[p])            printf("lose\n");        else {            int ans;            while (N) {                if (N >= a[p]) {                    N -= a[p];                    ans = a[p];                }                p--;            }            printf("%d\n", ans);        }    }    return 0;}

coreldraw x5啟用碼

你給的安裝代碼不行,換個吧。
安裝代碼:X6FH-3J45-TT7X-J567-RAS8
序號:DR15R22-DS48YWY-MUDYDGJ-WX7THLY
啟用碼:5876-0C27-1432-0F59-1567
試試看!
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.