CF676E.The Last Fight Between Human and AI
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
100 years have passed since the last victory of the man versus computer in Go. Technologies made a huge step forward and robots conquered the Earth! It's time for the final fight between human and robot that will decide the faith of the planet.
The following game was chosen for the fights: initially there is a polynomial
P(x) = a__n__x__n + a__n - 1_x__n_ - 1 + ... + a_1_x + _a_0,
with yet undefined coefficients and the integer k. Players alternate their turns. At each turn, a player pick some index j, such that coefficient a__j that stay near x__j is not determined yet and sets it to any value (integer or real, positive or negative, 0 is also allowed). Computer moves first. The human will be declared the winner if and only if the resulting polynomial will be divisible by Q(x) = x - k.
Polynomial P(x) is said to be divisible by polynomial Q(x) if there exists a representation P(x) = B(x)Q(x), where B(x) is also some polynomial.
Some moves have been made already and now you wonder, is it true that human can guarantee the victory if he plays optimally?
距人类在围棋中最后一次战胜计算机已过去100年。技术取得了巨大进步,机器人已征服地球!现在,决定星球命运的人机终极对决即将展开。
对决所采用的游戏规则如下:初始时给定一个多项式
P(x)=anxn+an−1xn−1+⋯+a1x+a0,
其系数尚未确定,另给定一个整数 k。双方轮流行动。每次轮到某方时,该方需选择一个下标 j,使得尚未确定的系数 aj(即 xj 项前的系数)存在,并将其赋为任意值(可为整数或实数、正数或负数,0 亦允许)。计算机先手。当最终得到的多项式 P(x) 可被 Q(x)=x−k 整除时,人类获胜。
称多项式 P(x) 可被多项式 Q(x) 整除,当且仅当存在某个多项式 B(x),使得 P(x)=B(x)Q(x) 成立。
目前已有若干步操作完成,那么问题来了:若人类采取最优策略,是否一定能保证获胜?
输入格式
The first line of the input contains two integers n and k (1 ≤ n ≤ 100 000, |k| ≤ 10 000) — the size of the polynomial and the integer k.
The i-th of the following n + 1 lines contain character '?' if the coefficient near x__i - 1 is yet undefined or the integer value a__i, if the coefficient is already known ( - 10 000 ≤ a__i ≤ 10 000). Each of integers a__i (and even a__n) may be equal to 0.
Please note, that it's not guaranteed that you are given the position of the game where it's computer's turn to move.
输入的第一行包含两个整数 n 和 k(1≤n≤100000,∣k∣≤10000)——分别表示多项式的次数和整数 k。
接下来的 n+1 行中,第 i 行(1≤i≤n+1)包含一个字符 '?',表示 xi−1 项的系数尚未确定;或者包含一个整数 ai,表示该系数已知(−10000≤ai≤10000)。每个整数 ai(甚至包括 an)都可能为 0。
请注意,题目所给的局面并不保证是轮到计算机行动的局面。
输出格式
Print "Yes" (without quotes) if the human has winning strategy, or "No" (without quotes) otherwise.
如果人类有必胜策略,则输出 "Yes"(不带引号),否则输出 "No"(不带引号)。
输入输出样例
输入#1
1 2 -1 ?
输出#1
Yes
输入#2
2 100 -10000 0 1
输出#2
Yes
输入#3
4 5 ? 1 ? 1 ?
输出#3
No
说明/提示
In the first sample, computer set _a_0 to - 1 on the first move, so if human can set coefficient _a_1 to 0.5 and win.
In the second sample, all coefficients are already set and the resulting polynomial is divisible by x - 100, so the human has won.
在第一个样例中,计算机在第一步将系数 a0 设为 −1,因此人类玩家可将系数 a1 设为 0.5 并获胜。
在第二个样例中,所有系数均已确定,所得多项式可被 x−100 整除,因此人类玩家获胜。
输入解题思路,AI测评打分。不知道怎么写?