Skip to content

Commit 5a2518a

Browse files
author
Joshua Goller
committed
intermittent commit of codeforces stuff
1 parent 8e7079c commit 5a2518a

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed
File renamed without changes.

codeforces/1a/input.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
6 6 4 4
2+
0 0 5 0
3+
5 5 1 25
4+
1000000000 1000000000 1000000000 1
5+
1000000000 1000000000 500000000 4
6+
10 1 3 4

codeforces/1a/solution.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
3+
In - three ints
4+
Out - int
5+
Constraints:
6+
- in ints are 1 <= val <= 10^9 (1 000 000 000) (don't need to test for div by
7+
0)
8+
- sides must be parallel; no diagonals
9+
-------------------------------
10+
Total area is n * m
11+
Each flagstone covers a * a space
12+
k * (a * a) >= n * m
13+
k = (n * m) / (a * a)
14+
k * (4 * 4) >= 6 * 6
15+
k * (16) >= 36
16+
This doesn't work though because it would involve breaking up a square.
17+
18+
First calculate how many are vertically required:
19+
n / a + (add 1 if any remainder)
20+
then calculate how many are horizontally required.
21+
m / a + (add 1 if any remainder)
22+
23+
then multiply results.
24+
---------------------
25+
Cases:
26+
- a > m; only need 1
27+
- a = m; only need 1
28+
- a < m;
29+
- same for a and n
30+
*/
31+
32+
#include <bits/stdc++.h>
33+
34+
using namespace std;
35+
36+
int main() {
37+
int n, m, a;
38+
int ans;
39+
freopen("input.txt", "r", stdin);
40+
while (scanf("%d %d %d %d", &n, &m, &a, &ans) == 4) {
41+
int vertical = (n / a + (n % a ? 1 : 0));
42+
int horizontal = (m / a + (m % a ? 1 : 0));
43+
cout << "v: " << vertical << "h: " << horizontal << endl;
44+
cout << vertical * horizontal << endl;
45+
assert((vertical * horizontal) == ans);
46+
}
47+
return 0;
48+
}

templates/cpp/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include ../../makefiles/settings.mk
2+
include ../../makefiles/cpp-competitive-compile.mk
3+
include ../../makefiles/build.mk
File renamed without changes.

0 commit comments

Comments
 (0)