zoukankan      html  css  js  c++  java
  • CodeForces 32C. Flea 水题

    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
    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;
    }
  • 相关阅读:
    poj 2104(线段树)
    poj 1962(并查集+带权更新)
    hdu 2818(并查集,带权更新)
    hdu 1856
    hdu 3172
    hdu 1325(并查集)
    hdu 5023
    pku 2777(经典线段树染色问题)
    hdu 1671(字典树判断前缀)
    hdu 1247 (字典树入门)
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4230863.html
Copyright © 2011-2022 走看看