题目:小红和小紫博弈,一个2*n的矩阵,小小红在(1,1),要前往(n,1)或(n,2),小红希望路程尽可能小,小紫希望路程尽可能大。

知识点:博弈

思路:

其实挺简单的博弈题,画图可知:alt

首先最短路为n-1,然后每五列必出一次换行,所以长度为n-1+n/5;

#include<bits/stdc++.h>
using namespace std;
void slove() {
	int n; cin>>n;
	if(n==1) cout<<0<<endl;
	else if(n==2) cout<<1<<endl;
	else cout<<n-1+n/5<<endl;
}
int main() {
	int t; cin>>t;
	while(t--) slove();
}