博弈论刷题记录

2024-05-16 06:28
文章标签 记录 刷题 博弈论

本文主要是介绍博弈论刷题记录,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 //不想学新东西了(

肥猫的游戏

#include<bits/stdc++.h>
using namespace std;
int n;
bool check(int x,int y,int z){int pos=0;int m;m=y-x;if(m==1||m==n-1)pos++;m=z-y;if(m==1||m==n-1)pos++;m=z-x;if(m==1||m==n-1)pos++;if(pos==2)return 1;return 0;
}
void solve(){cin>>n;int a[3];cin>>a[0]>>a[1]>>a[2];sort(a,a+3);for(int i=1;i<n-2;i++){int x,y,z;cin>>x>>y>>z;}if(check(a[0],a[1],a[2])){cout<<"JMcat Win"<<endl;return ;}else{if((n-2)&1)cout<<"PZ Win"<<endl;else cout<<"JMcat Win"<<endl;}
}
int main(){ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t;// cin>>t;t=1;while(t--)solve();return 0;
}

Roy&October之取石子

#include<bits/stdc++.h>
using namespace std;
void solve(){int n;cin>>n;if(n%6==0)cout<<"Roy wins!"<<endl;else cout<<"October wins!"<<endl;
}
int main(){ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t;cin>>t;//t=1;while(t--)solve();return 0;
}

[NOIP2010 普及组] 三国游戏

#include<bits/stdc++.h>
using namespace std;
void solve(){int n;cin>>n;vector<vector<int>>a(n+1,vector<int>(n+1));for(int i=0;i<n;i++){for(int j=i+1;j<n;j++){cin>>a[i][j];a[j][i]=a[i][j];}}int ans=0;for(int i=0;i<n;i++){sort(a[i].begin(),a[i].end());ans=max(ans,a[i][n-1]);}cout<<1<<endl<<ans<<endl;
}
int main(){ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t;// cin>>t;t=1;while(t--)solve();return 0;
}

取数游戏 II

#include<bits/stdc++.h>
using namespace std;
void solve(){int n;cin>>n;vector<int>a(n+1);for(int i=1;i<=n;i++)cin>>a[i];for(int i=1;i<=n;i++){if(a[i]==0){if(i%2==0){cout<<"YES"<<endl;return ;}break;}}for(int i=n;i>=1;i--){if(a[i]==0){if((n-i+1)%2==0){cout<<"YES"<<endl;return ;}break;}}cout<<"NO"<<endl;
}
int main(){ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t;// cin>>t;t=1;while(t--)solve();return 0;
}

欧几里德的游戏

#include<bits/stdc++.h>
using namespace std;
void solve(){int a,b;cin>>a>>b;bool p=1;while(a&&b){if(a<b)swap(a,b);if(a>=2*b){if(p)cout<<"Stan wins"<<endl;else cout<<"Ollie wins"<<endl;return ;}else {a-=b;if(a==0){if(p)cout<<"Stan wins"<<endl;else cout<<"Ollie wins"<<endl;}}p=!p;}
}
int main(){ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t;cin>>t;//t=1;while(t--)solve();return 0;
}

Roy&October之取石子II

#include<bits/stdc++.h>
using namespace std;
void solve(){int x;cin>>x;if(x%4==0)cout<<"Roy wins!"<<endl;else cout<<"October wins!"<<endl;
}
int main(){ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t;cin>>t;//t=1;while(t--)solve();return 0;
}

pb的游戏(1)

#include<bits/stdc++.h>
using namespace std;
void solve(){int n;cin>>n;if(n&1)cout<<"zs wins"<<endl;else cout<<"pb wins"<<endl;
}
int main(){ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t;cin>>t;//t=1;while(t--)solve();return 0;
}

[DMOI-R1] 柯基棋

#include<bits/stdc++.h>
using namespace std;
void solve(){int n,q,s;cin>>n>>q>>s;if(n&1)cout<<"A won"<<endl;else cout<<"B won"<<endl;
}
int main(){ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t;cin>>t;//t=1;while(t--)solve();return 0;
}

[UESTCPC 2024] 取数游戏

#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve(){int n;cin>>n;vector<int>a(n+1);int sum=0;for(int i=1;i<=n;i++)cin>>a[i],sum+=a[i];for(int i=1;i<=n;i++){if(a[i]>sum/2){cout<<"YES"<<endl;return ;}}if(n&1)cout<<"NO"<<endl;else cout<<"YES"<<endl;
}
signed main(){ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t;cin>>t;//t=1;while(t--)solve();return 0;
}

「LAOI-5」拼图

#include<bits/stdc++.h>
using namespace std;
void solve(){int n;cin>>n;if(n>5)cout<<"Alice"<<endl;else cout<<"Shinobu"<<endl;
}
int main(){ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t;cin>>t;//t=1;while(t--)solve();return 0;
}

这篇关于博弈论刷题记录的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/994123

相关文章

Python获取中国节假日数据记录入JSON文件

《Python获取中国节假日数据记录入JSON文件》项目系统内置的日历应用为了提升用户体验,特别设置了在调休日期显示“休”的UI图标功能,那么问题是这些调休数据从哪里来呢?我尝试一种更为智能的方法:P... 目录节假日数据获取存入jsON文件节假日数据读取封装完整代码项目系统内置的日历应用为了提升用户体验,

Spring Boot 配置文件之类型、加载顺序与最佳实践记录

《SpringBoot配置文件之类型、加载顺序与最佳实践记录》SpringBoot的配置文件是灵活且强大的工具,通过合理的配置管理,可以让应用开发和部署更加高效,无论是简单的属性配置,还是复杂... 目录Spring Boot 配置文件详解一、Spring Boot 配置文件类型1.1 applicatio

MySQL INSERT语句实现当记录不存在时插入的几种方法

《MySQLINSERT语句实现当记录不存在时插入的几种方法》MySQL的INSERT语句是用于向数据库表中插入新记录的关键命令,下面:本文主要介绍MySQLINSERT语句实现当记录不存在时... 目录使用 INSERT IGNORE使用 ON DUPLICATE KEY UPDATE使用 REPLACE

Python 中的异步与同步深度解析(实践记录)

《Python中的异步与同步深度解析(实践记录)》在Python编程世界里,异步和同步的概念是理解程序执行流程和性能优化的关键,这篇文章将带你深入了解它们的差异,以及阻塞和非阻塞的特性,同时通过实际... 目录python中的异步与同步:深度解析与实践异步与同步的定义异步同步阻塞与非阻塞的概念阻塞非阻塞同步

Python Dash框架在数据可视化仪表板中的应用与实践记录

《PythonDash框架在数据可视化仪表板中的应用与实践记录》Python的PlotlyDash库提供了一种简便且强大的方式来构建和展示互动式数据仪表板,本篇文章将深入探讨如何使用Dash设计一... 目录python Dash框架在数据可视化仪表板中的应用与实践1. 什么是Plotly Dash?1.1

Spring Boot中定时任务Cron表达式的终极指南最佳实践记录

《SpringBoot中定时任务Cron表达式的终极指南最佳实践记录》本文详细介绍了SpringBoot中定时任务的实现方法,特别是Cron表达式的使用技巧和高级用法,从基础语法到复杂场景,从快速启... 目录一、Cron表达式基础1.1 Cron表达式结构1.2 核心语法规则二、Spring Boot中定

国内环境搭建私有知识问答库踩坑记录(ollama+deepseek+ragflow)

《国内环境搭建私有知识问答库踩坑记录(ollama+deepseek+ragflow)》本文给大家利用deepseek模型搭建私有知识问答库的详细步骤和遇到的问题及解决办法,感兴趣的朋友一起看看吧... 目录1. 第1步大家在安装完ollama后,需要到系统环境变量中添加两个变量2. 第3步 “在cmd中

Spring Retry 实现乐观锁重试实践记录

《SpringRetry实现乐观锁重试实践记录》本文介绍了在秒杀商品SKU表中使用乐观锁和MybatisPlus配置乐观锁的方法,并分析了测试环境和生产环境的隔离级别对乐观锁的影响,通过简单验证,... 目录一、场景分析 二、简单验证 2.1、可重复读 2.2、读已提交 三、最佳实践 3.1、配置重试模板

在 Spring Boot 中使用异步线程时的 HttpServletRequest 复用问题记录

《在SpringBoot中使用异步线程时的HttpServletRequest复用问题记录》文章讨论了在SpringBoot中使用异步线程时,由于HttpServletRequest复用导致... 目录一、问题描述:异步线程操作导致请求复用时 Cookie 解析失败1. 场景背景2. 问题根源二、问题详细分

关于Spring @Bean 相同加载顺序不同结果不同的问题记录

《关于Spring@Bean相同加载顺序不同结果不同的问题记录》本文主要探讨了在Spring5.1.3.RELEASE版本下,当有两个全注解类定义相同类型的Bean时,由于加载顺序不同,最终生成的... 目录问题说明测试输出1测试输出2@Bean注解的BeanDefiChina编程nition加入时机总结问题说明