結果
問題 | No.84 悪の算盤 |
ユーザー |
![]() |
提出日時 | 2017-06-28 20:38:47 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 52 ms / 5,000 ms |
コード長 | 3,861 bytes |
コンパイル時間 | 2,319 ms |
コンパイル使用メモリ | 79,656 KB |
実行使用メモリ | 37,464 KB |
最終ジャッジ日時 | 2024-10-13 09:01:43 |
合計ジャッジ時間 | 3,550 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
import java.io.ByteArrayInputStream;import java.io.IOException;import java.io.InputStream;import java.io.PrintWriter;import java.util.Arrays;import java.util.InputMismatchException;import java.io.OutputStream;import java.util.StringTokenizer;import java.io.BufferedReader;import java.io.InputStreamReader;import java.util.HashMap;import java.util.Map;import java.util.ArrayList;import java.util.List;import java.util.Scanner;import java.math.BigDecimal;/*** Built using CHelper plug-in* Actual solution is at the top*/public class Main {public static void main(String[] args) {InputStream inputStream = System.in;OutputStream outputStream = System.out;InputReader in = new InputReader(inputStream);PrintWriter out = new PrintWriter(outputStream);Task solver = new Task();solver.solve(1, in, out);out.close();}static class Task {public void solve(int testNumber, InputReader in, PrintWriter out) {long R = in.nextLong();long C = in.nextLong();if(R==C) out.println((R*C+3)/4-1);else out.println((R*C+1)/2-1);}}public static int[] sieveEratosthenes(int n) {if (n <= 32) {int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };for (int i = 0; i < primes.length; i++) {if (n < primes[i]) {return Arrays.copyOf(primes, i);}}return primes;}int u = n + 32;double lu = Math.log(u);int[] ret = new int[(int) (u / lu + u / lu / lu * 1.5)];ret[0] = 2;int pos = 1;int[] isnp = new int[(n + 1) / 32 / 2 + 1];int sup = (n + 1) / 32 / 2 + 1;int[] tprimes = { 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };for (int tp : tprimes) {ret[pos++] = tp;int[] ptn = new int[tp];for (int i = (tp - 3) / 2; i < tp << 5; i += tp)ptn[i >> 5] |= 1 << (i & 31);for (int j = 0; j < sup; j += tp) {for (int i = 0; i < tp && i + j < sup; i++) {isnp[j + i] |= ptn[i];}}}// 3,5,7// 2x+3=nint[] magic = { 0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, 31, 22, 28, 18, 26, 10, 7, 12, 21, 17,9, 6, 16, 5, 15, 14 };int h = n / 2;for (int i = 0; i < sup; i++) {for (int j = ~isnp[i]; j != 0; j &= j - 1) {int pp = i << 5 | magic[(j & -j) * 0x076be629 >>> 27];int p = 2 * pp + 3;if (p > n)break;ret[pos++] = p;if ((long) p * p > n)continue;for (int q = (p * p - 3) / 2; q <= h; q += p)isnp[q >> 5] |= 1 << q;}}return Arrays.copyOf(ret, pos);}static class InputReader {public BufferedReader reader;public StringTokenizer tokenizer;public InputReader(InputStream stream) {reader = new BufferedReader(new InputStreamReader(stream), 32768);tokenizer = null;}public String next() {while (tokenizer == null || !tokenizer.hasMoreTokens()) {try {tokenizer = new StringTokenizer(reader.readLine());} catch (IOException e) {throw new RuntimeException(e);}}return tokenizer.nextToken();}public int nextInt() {return Integer.parseInt(next());}public long nextLong() {return Long.parseLong(next());}}}