当前位置:网站首页>A. Theatre Square(codefore)
A. Theatre Square(codefore)
2022-06-30 15:01:00 【Rabbit doesn't like radish】
A. Theatre Square
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city’s anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a.
What is the least number of flagstones needed to pave the Square? It’s allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It’s not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square.
Input
The input contains three positive integer numbers in the first line: n, m and a (1 ≤ n, m, a ≤ 109).
Output
Write the needed number of flagstones.
Examples
inputCopy
6 6 4
outputCopy
4
The question : It's simple ,
AC:
#include<stdio.h>
#include<string.h>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
int n,m,a;
cin>>n>>m>>a;
ll x=ceil(n*1.0/a)*ceil(m*1.0/a);
//ll y=ceil(m*1.0/a);
cout<<x<<endl;
return 0;
}
ceil,,math function , Rounding up
Error code : Although it looks complicated , I just put the situation out for discussion and output , Even if I use long long, Still 1000000000 1000000000 1 In this case ,codeforce say Signed integer overflow . I don't know what I mean , But the code above will not , When I made this mistake, I still thought that the problem of high probability should be multiplied with high precision , Ha ha ha ,!!!!
#include<stdio.h>
#include<string.h>
#include<vector>
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int main()
{
int n,m,a;
cin>>n>>m>>a;
ll sum;
if(n%a==0)
{
if(m%a==0)
{
//ll sum;
sum=n/a*(m/a);// Signed integer overflow
cout<<sum<<endl;
}
else
{
sum=n/a*(m/a+1);
cout<<sum<<endl;
}
}
else
{
if(m%a==0)
{
sum=m/a*(n/a+1);
cout<<sum<<endl;
}
else
{
sum=(n/a+1)*(m/a+1);
cout<<sum<<endl;
}
}
return 0;
}
边栏推荐
- How to get palindrome number in MATLAB (using fliplr function)
- Knowledge learned from the water resources institute project
- Invalid argument during startup: Failed to open the . conf file: redis-window
- 1062 talent and virtue (25 points)
- Bucket sorting (C language)
- Experiment 2: stack
- IO interview questions
- Effect of shadow around the block after mouse over
- CCF command line options (Full Score code + problem solving ideas + skill summary) March 3, 2014
- Matlab finds a prime number that is greater than a given integer and follows this integer
猜你喜欢

Sum of CCF digits (full mark code + problem solving idea) 201512-1

Error $(...) size is not a function

CCF image rotation (Full Score code + problem solving idea) 201503-01

August 24, 2021 deque queue and stack

CCF sequence segmentation (Full Score code + problem solving idea) 201509 -1

@PathVariable

Svn password forgetting solution

How to use Alibaba Vector Icon

Not satisfied with markdown native code block style? Try this beautify code screenshot tool~~

Database connection to company database denied
随机推荐
[extensive reading of papers] analyzing connections between user attributes, images, and text
[matlab] 3D drawing summary
PS cutting height 1px, Y-axis tiling background image problem
Binary rotation array (1)
C language \t usage
1107 social clusters (30 points)
JS time conversion standard format, timestamp conversion standard format
Quick sort (C language)
Location of dichotomy
Upgrade centos7 mysql5.5 to mysql5.7 non RPM in the form of tar package
Svn password forgetting solution
Win10 backup backup shows that creating a shared protection point on the shadow failed
G - navigation nightare
Add attributes to multimode
val_ Loss decreases first and then increases or does not decrease but only increases
For loop and promise to solve the problem of concurrent callback
V3 03_ Getting started
Matlab calculates the factorial sum of the first n numbers (easy to understand)
Text matching - [naacl 2021] augsbert
Why do high precision CNC machining centers have errors? You should pay attention to these four reasons!