当前位置:网站首页>Codeforces 1629 F1. Game on sum (easy version) - DP, game, thinking
Codeforces 1629 F1. Game on sum (easy version) - DP, game, thinking
2022-06-12 13:32:00 【Tianyi City*】
The question :
You have a number on your hand , At first it was 0, You can choose each time [0,k] Any real number in . Then it is up to the opponent to add or subtract this number . in total n round , And the opponent must have at least m Round plus the number in your hand . You want the numbers to be as big as possible , The opponent wants the number to be as small as possible . If you both make the best choice , Ask the maximum number .
Answer key :
game … I'm a real dish . that 2000 The left-right game can push me on the ground and rub , Still need more practice
At the beginning, I wanted to follow it , I can't even model an example QAQ.
So set dp[n][m] Take a total of... For the present n round , The opponent should at least add m round .
After taking a round , Since the previous decision does not affect the subsequent situation , So either dp[n-1][m], Or become dp[n-1][m-1].
Suppose that the current round is x. So there are two cases in all :
1.dp[n-1][m-1]+x
2.dp[n-1][m]-x
Which opponent will take ? Of course, the smallest one min(dp[n-1][m-1]+x,dp[n-1][m]-x).
How to make this value as large as possible ? When x=(dp[n-1][m-1]+dp[n-1][m])/2 When .
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const int N=2e3+5;
ll dp[N][N];
ll qpow(ll a,ll b){
ll ans=1;for(;b;a=a*a%mod,b>>=1)if(b&1)ans=ans*a%mod;return ans;}
int main()
{
int inv=qpow(2,mod-2);
for(int i=1;i<N;i++)dp[i][i]=i;
for(int i=2;i<N;i++)
for(int j=1;j<i;j++)
dp[i][j]=(dp[i-1][j]+dp[i-1][j-1])*inv%mod;
int t;
scanf("%d",&t);
while(t--){
int n,m,k;
scanf("%d%d%d",&n,&m,&k);
printf("%lld\n",dp[n][m]*k%mod);
}
return 0;
}
边栏推荐
- Cocoapods的相关知识点
- C#DBHelper_ FactoryDB_ GetConn
- 关于#SQLite写注册功能时,数据表查询出错#的问题,如何解决?
- import torch_geometric 第一个图网络例子
- 1005: estimation of the earth's population carrying capacity
- Realization of Joseph Ring with one-way ring linked list
- 【云原生 | Kubernetes篇】深入了解Ingress
- 镜像扫描工具预研
- 2061: [example 1.2] trapezoidal area
- 【云原生 | Kubernetes篇】深入了解Deployment(八)
猜你喜欢

Wechat web developer tools tutorial, web development issues

Experience and learning path of introductory deep learning and machine learning

618进入后半段,苹果占据高端市场,国产手机终于杀价竞争

leetcode 47. Permutations II 全排列 II(中等)

go-zero 微服务实战系列(二、服务拆分)

import torch_ Data view of geometric

事件的传递和响应以及使用实例

Pytorch to onnx, onnxruntime reasoning in mmclas
![2061: [example 1.2] trapezoidal area](/img/83/79b73ca10615c852768aba8d2a5049.jpg)
2061: [example 1.2] trapezoidal area

章鱼网络进展月报 | 2022.5.1-5.31
随机推荐
Script import CDN link prompt net:: err_ FILE_ NOT_ Found problem
Automatic Generation of Visual-Textual Presentation Layout
torch_ About the geometric Mini batch
Tensorrt, onnx to tensorrt in mmclas
Innovation training (XII) project summary
2066: [example 2.3] buying books
镜像扫描工具预研
[EDA] chip layout design: VLSI layout design using electric
D1 哪吒开发板 了解基本的启动加载流程
How to adapt the page size when iframe is embedded in a web page
Semantic segmentation with pytorch
GPUImage链式纹理的简单实现
C language [23] classic interview questions [2]
智能垃圾桶语音芯片应用设计方案介绍,WT588F02B-8S
Informatics Olympiad all in one 2059: [example 3.11] buy a pen
当字节跳动在美国输出中国式 996
创新实训(十)高级界面美化
1002: output the second integer
Summary of question brushing in leetcode sliding window
TCP的“非”可靠性