Skip to content

Commit 4d89639

Browse files
committed
optimize
1 parent 7fc91eb commit 4d89639

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

codeForces/codeForces_1A_A_Theatre_Square.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,22 @@
22
* 思路:矩形用小正方形填充,只需行和列取整就行了。
33
* 注意陷阱,不要用 int32,否则结果打印不了最大 10^18 这样的大数
44
* AC:
5-
* Time:31 ms Memory:0 KB
5+
* Time:30 ms Memory:0 KB
66
*
77
*/
88
#include<stdio.h>
99
#include<map>
1010
#include<utility>
11+
#include<math.h>
1112

1213
using namespace std;
1314

1415
int main()
1516
{
1617
int n, m, a;
17-
long long row = 0, col = 0, ans = 0;
18+
long long ans = 0;
1819
scanf("%d%d%d", &n, &m, &a);
19-
if (n % a == 0) {
20-
col = n / a;
21-
}
22-
else {
23-
col = n / a + 1;
24-
}
25-
if (m % a == 0) {
26-
row = m / a;
27-
}
28-
else {
29-
row = m / a + 1;
30-
}
31-
32-
ans = row * col;
20+
ans = ceil((double)n / a) * ceil((double)m / a); // floor() 和 ceil() 的入参都是 double型
3321
printf("%lld", ans);
3422
return 0;
3523
}

0 commit comments

Comments
 (0)