麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發(fā)設計 > 正文

【POJ 2348 Euclid's Game】 + 博弈

2019-11-11 05:01:43
字體:
供稿:網(wǎng)友

Euclid’s Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9172 Accepted: 3756

Description Two players, Stan and Ollie, play, starting with two natural numbers. Stan, the first player, subtracts any positive multiple of the lesser of the two numbers from the greater of the two numbers, PRovided that the resulting number must be nonnegative. Then Ollie, the second player, does the same with the two resulting numbers, then Stan, etc., alternately, until one player is able to subtract a multiple of the lesser number from the greater to reach 0, and thereby wins. For example, the players may start with (25,7):

25 7 11 7 4 7 4 3 1 3 1 0

an Stan wins.

Input The input consists of a number of lines. Each line contains two positive integers giving the starting two numbers of the game. Stan always starts.

Output For each line of input, output one line saying either Stan wins or Ollie wins assuming that both of them play perfectly. The last line of input contains two zeroes and should not be processed.

Sample Input

34 12 15 24 0 0

Sample Output

Stan wins Ollie w

若出現(xiàn) N - M > M 情況是否為自由態(tài)?

AC代碼:

#include<cstdio>#include<algorithm>using namespace std;typedef long long LL;int main(){ LL N,M; while(scanf("%lld %lld",&N,&M) != EOF){ if(N == 0 && M == 0) break; bool ok = true; while(1){ if(N < M) swap(N,M); if(N % M == 0 || (N > 2 * M)) break; N -= M; ok = !ok; } if(ok) printf("Stan wins/n"); else printf("Ollie wins/n"); } return 0;}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 国产美女精品视频 | 最新在线黄色网址 | 日韩视频在线视频 | 二级大黄大片高清在线视频 | 免费观看一区二区三区 | 日韩av成人 | 日韩av日韩| 蜜桃精品视频 | 狠狠操天天射 | 中文字幕 亚洲一区 | 成人毛片视频免费看 | 国产一区精品在线观看 | 日韩美香港a一级毛片免费 日韩激情 | 欧美成人a | 成码无人av片在线观看网站 | 一本色道久久99精品综合蜜臀 | 国产91久久精品一区二区 | 特级a欧美做爰片毛片 | 九一免费国产 | 在线成人毛片 | 欧美一级黄色影院 | 亚洲国产色婷婷 | www.成人在线 | 国产手机av在线 | 亚洲啊v在线观看 | www.guochanav.com | 最新av在线播放 | 一级黄色国产视频 | 91短视频免费 | 7777在线观看| 18欧美性xxxx极品hd | 国产成人综合在线视频 | 久久艹国产精品 | 久久久久久久久久性 | 91精品国产92久久久久 | 亚州成人在线观看 | 色污视频在线观看 | 爱爱插插视频 | 插插操| 久久亚洲春色中文字幕久久 | 国产成年免费视频 |