题解:P13556 【MX-X15-T3】画圈圈
题目解法
数学题,显然被画圈圈的格子都是斜线排列。
举一个
黄线的位置就是最小网格右下角可以选的位置,蓝框就是一个例子,只要网格右下角在黄线上,那么它的
直接考虑网格为一条线的情况吧。
显然,
答案即为
特别考虑
还有
code
#include<bits/stdc++.h>
#define endl '\n'
#define r0 return 0
#define inf (0x7fffffff)
#define maxn ( 100000 +5)
#define int long long
using namespace std;
inline int read(){int x=0,f=1;char ch=getchar();while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}return x*f;}
int t;
signed main(){
cin >> t;
while(t--){
int k,l;
cin >> k >> l;
if(k==2)cout << ceil(2*sqrt(2*l)) << endl;
else{
if(l==1)cout << "2\n";
else{cout << (l-1)*k+1 << endl;}
}
}
}