CodeForces 32C. Flea 水题
It is known that fleas in Berland can jump only vertically and horizontally, and the length of the jump is always equal to s centimeters. A flea has found herself at the center of some cell of the checked board of the size n × m centimeters (each cell is 1 × 1 centimeters). She can jump as she wishes for an arbitrary number of times, she can even visit a cell more than once. The only restriction is that she cannot jump out of the board.
The flea can count the amount of cells that she can reach from the starting position (x, y). Let's denote this amount by dx, y. Your task is to find the number of such starting positions (x, y), which have the maximum possible value of dx, y.
The first line contains three integers n, m, s (1 ≤ n, m, s ≤ 106) — length of the board, width of the board and length of the flea's jump.
Output the only integer — the number of the required starting positions of the flea.
2 3 1000000
6
3 3 2
4
题意:大概就是讲的有一只青蛙,可以在n*m的格子上乱跳,每次最多跳S,问能够跳最多次数的起点总共能有多少个
题解:拿草稿本稍微画画,然后乱搞应该就可以了= =
#include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) const int inf=0x7fffffff; //无限大 int main() { ll n,m,s; while(cin>>n>>m>>s){ if(m>n) swap(n,m); ll ans=((n-1)/s+1)*((m-1)/s+1)*((n-1)%s+1)*((m-1)%s+1); cout<<ans<<endl; } return 0; }