当前位置:网站首页>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;
}
边栏推荐
- 文本匹配——【NAACL 2022】GPL
- How to program and process such parts?
- CCF sequence segmentation (Full Score code + problem solving idea) 201509 -1
- Greedy interval problem (5)
- CCF date calculation (Full Score code + skill summary) February 2, 2015
- Win10 backup backup shows that creating a shared protection point on the shadow failed
- How many questions can you answer for the interview of Mechanical Engineer?
- 1025 pat ranking (25 points)
- Shangpinhui knowledge points of large e-commerce projects
- Using member variables and member functions of a class
猜你喜欢
CCF image rotation (Full Score code + problem solving idea) 201503-01
Computer screenshot how to cut the mouse in
ES6 notes
CCF command line options (Full Score code + problem solving ideas + skill summary) March 3, 2014
Shangpinhui knowledge points of large e-commerce projects
[matlab] 3D drawing summary
CCF Z-scan (full mark code + problem solving ideas) 201412-2
Solve the problem that codeblocks20.03 on win11 cannot run for the first time
[email protected][])"/>
NoViableAltException([email protected][])
Sum of CCF digits (full mark code + problem solving idea) 201512-1
随机推荐
1025 pat ranking (25 points)
1019 general palindromic number (20 points)
CCF string matching (Full Score code + problem solving ideas + skill summary) March 3, 2014
Why do high precision CNC machining centers have errors? You should pay attention to these four reasons!
1150 traveling salesman problem (25 points)
How does hbuilder display in columns?
Matlab two-dimensional array example (extract data)
August 24, 2021 deque queue and stack
Sum of CCF digits (full mark code + problem solving idea) 201512-1
Double pointer circular linked list
Using member variables and member functions of a class
Win10 backup backup shows that creating a shared protection point on the shadow failed
Not satisfied with markdown native code block style? Try this beautify code screenshot tool~~
How many questions can you answer for the interview of Mechanical Engineer?
Quick sort (C language)
Win10 one click Reset win10 to solve all system bugs without deleting any files and Applications
[extensive reading of papers] multimodal attribute extraction
@PathVariable
1136: password translation
K - rochambau (joint search, enumeration)