CodeForces 32C. Flea 水题
2015-01-17 18:06
609 查看
C. Flea
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Input
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
Output the only integer — the number of the required starting positions of the flea.
Sample test(s)
Input
Output
Input
Output
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Input
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
Output the only integer — the number of the required starting positions of the flea.
Sample test(s)
Input
2 3 1000000
Output
6
Input
3 3 2
Output
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; }
相关文章推荐
- Codeforces 451B Sort the Array(水题)
- Codeforces--400A--Inna and Choose Options(模拟水题)
- CodeForces 732A Buy a Shovel (水题)
- Triangle - CodeForces 407A 水题
- CodeForces 487A(水题)
- Codeforces 459A Pashmak and Garden(水题)
- CodeForces 703A Mishka and Game(玩骰子游戏,水题)
- Codeforces 735B Urbanization【水题】
- CodeForces 632A Grandma Laura and Apples(水题)
- Codeforces 660A:Co-prime Array(水题+思维)
- Codeforces 766C. Mahmoud and a Message 水题详解+错点记录
- codeforces 141A Amusing Joke(模拟水题)
- codeforces 669B B. Little Artem and Grasshopper(水题)
- CodeForces 482A-构造水题
- Codeforces 84A:Toy Army(水题)
- CodeForces 492A Vanya and Cubes(水题)
- CodeForces 719B Anatoly and Cockroaches (水题贪心)
- CodeForces 722B Verse Pattern (水题)
- Codeforces Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar(水题)
- Codeforces 385A Bear and Raspberry(水题)