当前位置:网站首页>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;
}
边栏推荐
- Binary rotation array (2)
- CCF drawing (full mark code + problem solving ideas + skill summary) February 2, 2014
- Finding the root of an integer by dichotomy
- Matlab function for limit, definite integral, first-order derivative, second-order derivative (classic examples)
- G - navigation nightare
- Matlab two-dimensional array example (extract data)
- Knowledge learned from the water resources institute project
- The difference between settimeout() and setinterval()
- The kth largest element in the sorted array
- CCF Z-scan (full mark code + problem solving ideas) 201412-2
猜你喜欢

Component communication mode

Matlab function for limit, definite integral, first-order derivative, second-order derivative (classic examples)

CCF elimination games (Full Score code + problem solving ideas + skill summary) February 2, 2015

day02

PS cutting height 1px, Y-axis tiling background image problem

CCF window (Full Score code + problem solving idea) March 2, 2014

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

ES6 notes

CCF string matching (Full Score code + problem solving ideas + skill summary) March 3, 2014

CCF call auction (full mark code + problem solving ideas + skill summary) 201412 - 3
随机推荐
1133: output family and friends string
左旋梯形螺纹的编程
Computer screenshot how to cut the mouse in
The kth largest element in the sorted array
K - rochambau (joint search, enumeration)
中信期货开户麻烦吗安全吗,期货开户手续费是多少,能优惠吗
Shangpinhui knowledge points of large e-commerce projects
1 figure to explain the difference and connection between nodejs and JS
JS time conversion standard format, timestamp conversion standard format
1018 public bike Management (30 points)
1035 password (20 points)
1015 reversible primes (20 points)
Implement a long-click list pop-up box on apiccloud
CCF Z-scan (full mark code + problem solving ideas) 201412-2
Knowledge learned from the water resources institute project
Add attributes to multimode
CCF elimination games (Full Score code + problem solving ideas + skill summary) February 2, 2015
Solve the problem that codeblocks20.03 on win11 cannot run for the first time
立式加工中心调试的步骤
高精度CNC加工中心为什么会出现误差?这4个原因你要注意!