P7901 「PMOI-0」潇湘之雨

· · 题解

P7901题解

本题思路:

  1. 因为每一轮移动必须正好经过矩阵上的所有点,且不能经过矩阵外的点,也不能经过重复的点。

  2. 并且我们知道,每一轮移动能走过 4\times n \times n 个格子。

  3. 还有,必有一个点,从此点出发,能走过除题目给出的点的所有点。

  4. 所以此题的公式为—— \dfrac{4 \times n \times n}{k} 这就是这题的答案,不要忘记用六十四位整型变量哦。

接下来——上代码。

#include<bits/stdc++.h>
using namespace std;
long long read() //快读模板,注意数据范围
{
    long long 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<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
int main()
{
    cin.tie(0);
    cout.tie(0);
    long long n=read(), k=read(), x=read(), y=read();
    cout<<k/(n*n*4); //套公式
    return 0;
}