日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

第十一届河南省赛--H : Attack City and Capture Territory

發布時間:2024/4/18 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 第十一届河南省赛--H : Attack City and Capture Territory 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目鏈接
The Three Kingdoms period was a relatively famous period in the history of China. From the Battle of Chibi (AD 211) to the reunification of China in the Western Jin Dynasty(AD 280). During the period, Cao’s Wei State, Liu’s Shu State, and Sun’s Wu Guo’s Three Kingdoms stood together. Therefore, it was called the Three Kingdoms period.

In the last years of the Eastern Han Dynasty, Dong_ Z specialized in power , the coalition forces of the world’s princes crusade against each other. Among them, Liu_B and Sun_Q, who are school students, also participated in the crusade.

In AD 215 , Liu_B and Sun_Q simultaneously attacked JingZhou and directly threatened Dong Z’s city. There were N firepower points on the high wall, each fire point with different s trength Xi . Liu_B and Sun_Q looked at the high walls and the strong gates, they did not attack the city traightaway. They negotiate to attack firepower point alternately. Who breaks through the last firepower point, he will win the city.

Because of limited weaponry, weapons of each side can only attack one firepower at a time. But they can control whether completely destroy this firepower point or weaken the strength of firepower point.

Liu_B has a strong think-tank. After calculation, he finds out who will attack first , who will more likely win the city .

輸入

The first line of the input contains one integer T, which is the number of test cases (1<=T<=10). Each test case specifies:

  • Line 1: N ( 1 ≤ N ≤ 100 )

  • Line 2: X1 X2… Xn ( 1 <= Xi<=1000 i=1…. n)

輸出

For each test case , print “Liu_B is sure to win.” Or “Liu_B is not sure to win.” , suppose Liu_B first attacks.

樣例輸入

3
2
1 3
2
3 3
5
1 2 3 4 5

樣例輸出

Liu_B is sure to win.
Liu_B is not sure to win.
Liu_B is sure to win.

思路

尼姆博弈:N對東西,每次去n個,取完勝出。
做題少,一直沒好好做過博弈論的題,差這一道與銅牌失之交臂 比賽的時候,一直在找規律,一直WA。最后想寫個隨機算法,發現隨機算法也不會寫,真的是菜。。。

AC

#include<bits/stdc++.h> #define N 100005 using namespace std; int main () {// freopen("in.txt", "r", stdin);int t;scanf("%d", &t);while (t--) {int n, ans;scanf("%d%d", &n, &ans);for (int i = 1; i < n; i++) {int t;scanf("%d", &t);ans ^= t;}if (ans) printf("Liu_B is sure to win.\n");else printf("Liu_B is not sure to win.\n");} return 0; }

隨機

#include<bits/stdc++.h> #define N 100005 using namespace std; int main () {srand(time(0));rand();return 0; } #include<bits/stdc++.h> #define N 100005 using namespace std; int main () { // freopen("in.txt", "r", stdin);int t;scanf("%d", &t); // 把當前時間作為時間種子srand(time(0));while (t--) {int n;scanf("%d", &n);for (int i = 0; i < n; i++) {int temp;scanf("%d", &temp);} int flag; // cout << rand() << endl;flag = rand() % 2; if (flag) printf("Liu_B is sure to win.\n");else printf("Liu_B is not sure to win.\n");} return 0; }

總結

以上是生活随笔為你收集整理的第十一届河南省赛--H : Attack City and Capture Territory的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。