Codeforces 676E The Last Fight Between Human and AI 规律
2024-08-27 01:27:50
链接
题意
给一个多项式,有些系数不确定。人和机器轮流填系数,系数可以是任何数,问是否能使得最后的多项式整除 x-k
思路
整除x-k就等价 x=k时,多项式为0. 系数可以是任何数的话就能得到任何结果,只要人是否是填最后一个就行。
另外分 k=0 和 k<>0两种情况考虑。
代码
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#define LL long long
#define INF 0x3f3f3f3f
#define eps 1e-8
#define MAXN 100005
using namespace std;
int a[MAXN];
int main(){
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // ONLINE_JUDGE
int n, k;
while(~scanf("%d%d", &n, &k)){
int unk = 0;
for(int i = 0; i <= n; ++i){
char s[20];
scanf("%s", s);
if(s[0] == '?'){
a[i] = INF;
++unk;
}
else{
a[i] = atoi(s);
}
}
if(k == 0){
if(a[0] == 0){
printf("Yes\n");
}
else if(a[0] == INF){
if((n + 1 - unk) & 1){
printf("Yes\n");
}
else{
printf("No\n");
}
}
else{
printf("No\n");
}
}
else{
if(unk > 0){
if((n + 1) & 1){
printf("No\n");
}
else{
printf("Yes\n");
}
}
else{
double res = 0;
for(int i = n; i >= 0; --i){
res = res * k + a[i];
}
if(res == 0){
printf("Yes\n");
}
else{
printf("No\n");
}
}
}
}
}
最新文章
- c#如何判断webbrowser已经加载完毕
- substr 与 substring 的区别
- struts2配置文件中Action中的各属性的含义
- [LintCode] Candy 分糖果问题
- 图解 &; 深入浅出Java初始化与清理:构造器必知必会
- UITextView 点return 隐藏键盘
- poj 1459 Power Network : 最大网络流 dinic算法实现
- ASP.NET母版页与内容页相对路径的问题
- windows下redis 开机自启动
- ​C语言数组作为函数参数
- Cognos 图表用图片取代”没有数据显示”
- Nmap的使用【转载】
- AFN
- Java基础---IO(三)--IO包中的其他类
- python 自动化之路
- 一句话的事儿,Head first 设计模式
- phpstorm 一个窗口打开多个项目
- SpringBoot工程+热部署进行远程调试
- Go 语言相关的优秀框架,库及软件列表
- 搭建ReactNative时的最普遍的错误—— ";:CFBundleIdentifier";, Does Not Exist
热门文章
- JDBC整理
- 方括号在sqlserver中的作用
- SQlException 对象名无效
- 洛谷P1962 斐波那契数列(矩阵快速幂)
- SQLAlchemy tutorial
- linux系统管理-软件包管理
- 12、Camel: Content-Aware and Meta-path Augmented Metric Learning for Author Identification----作者识别
- 《Exception》第八次团队作业:Alpha冲刺(大结局)
- [BZOJ3438][洛谷P1361]小M的作物
- BZOJ 1176/2683 Mokia (三维偏序CDQ+树状数组)