CF: 1A (Theatre Square)


Problem link: http://codeforces.com/problemset/problem/1/A

Solution 1


// @BEGIN_OF_SOURCE_CODE

#include <cstdio>
#include <iostream>

using namespace std;

int main ()
{
    int n;
    int m;
    int a;

    scanf ("%d %d %d", &n, &m, &a);

    long long flagsByRow;
    
    if (n % a == 0) {
        flagsByRow = n / a;
        
    } else {
        flagsByRow = n / a;
        flagsByRow++;

    }

    long long flagsByColumn;
    
    if (m % a == 0) {
        flagsByColumn = m / a;
        
    } else {
        flagsByColumn = m / a;
        flagsByColumn++;

    }

    cout << flagsByRow * flagsByColumn << endl;

    return 0;
}

// @END_OF_SOURCE_CODE

Solution 2


// @BEGIN_OF_SOURCE_CODE

#include <cstdio>
#include <iostream>

using namespace std;

int main ()
{
    int n;
    int m;
    int a;

    scanf ("%d %d %d", &n, &m, &a);

    long long flagsByRow = n / a;

    if (n % a) flagsByRow++;

    long long flagsByColumn = m / a;

    if (m % a) flagsByColumn++;

    cout << flagsByRow * flagsByColumn << endl;

    return 0;
}

// @END_OF_SOURCE_CODE

Solution 3


// @BEGIN_OF_SOURCE_CODE

#include <cstdio>
#include <cmath>

using namespace std;

int main ()
{
    int n;
    int m;
    int a;

    scanf ("%d %d %d", &n, &m, &a);

    printf ("%0.lf\n", ceil(n / (double) a) * ceil (m / (double) a));

    return 0;
}

// @END_OF_SOURCE_CODE

Solution 4


// @BEGIN_OF_SOURCE_CODE

#include <cstdio>
#include <iostream>

using namespace std;

int main ()
{
    long long n;
    long long m;
    long long a;

    cin >> n >> m >> a;
    
    cout << ((n + a - 1) / a) * ((m + a - 1) / a) << endl; 

    return 0;
}

// @END_OF_SOURCE_CODE

Solution 5 (Author: Shishir)


// @Author: Shishir

#include<stdio.h>
#include<math.h>
long long int row,column,capture_size;
void total_stone()
{
    long long int c=0;
    long long int remaining_column=column;
    if(capture_size==1)printf("%lld\n",row*column);
    else
    {
        while(remaining_column>0)
        {
            c++;
            remaining_column-=capture_size;
        }

        printf("%lld\n",((long long int)(ceil)((double)row/capture_size))*c);
    }
}
int main()
{
    while(scanf("%lld %lld %lld",&row,&column,&capture_size)!=EOF)
    {
        total_stone();
    }
    return 0;
}

Advertisements

4 thoughts on “CF: 1A (Theatre Square)

  1. hello,
    thanks for solutions
    may you please review this solution and tell me why it’s refused ?

    #include
    using namespace std;

    int main() {
    int n, m, a;
    cin>>n>>m>>a;
    long long emad = ( (m%a == 0 ? m/a : m/a+1 ) * (m%a == 0? m/a : m/a+1) );
    cout<<emad<<endl;
    return 0;
    }

  2. you wrote m twice……i think one should be m,and the other is n;
    read your code care fully…..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s