summaryrefslogtreecommitdiffstats
path: root/šola/p1/dn/DN03_63230317.java
blob: 18ab302499c7eac94756f17035a5192e028b8488 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
public class DN03_63230317 {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextInt();
		long w = sc.nextInt();
		long k = sc.nextInt();
		if (w < h) { // a je to res potrebno
			w += h;
			h = w-h;
			w -= h;
		}
		long sum = 0;
		for (long i = 0; i < k; i++) 
			if ((w & (1 << i)) > 0) {
				long add = h/(1 << i);
				if (System.getenv("DN03_DEBUG") != null)
					System.err.println("po širini: i == " + i + ". dodal bom " + add);
				sum += add;
			}
		{
			long add = (w/(1 << k))*(h/(1 << k));
			if (System.getenv("DN03_DEBUG") != null)
				System.err.println("dodal bom " + add + " največjih");
			sum += add;
		}
		for (long i = 0; i < k; i++) {
			if ((h & (1 << i)) > 0) {
				long add = w/(1 << i);
				if (System.getenv("DN03_DEBUG") != null)
					System.err.println("po višini: i == " + i + ". dodal bom " + add);
				sum += add;
				if ((w & (1 << i)) > 0) {
					if (System.getenv("DN03_DEBUG") != null)
						System.err.println(w + " je skupen, odstranjujem eno");
					sum--;
				}
			}
		}
		System.out.println(sum);
	}
}