結果

問題 No.598 オーバーフローファンタジー
ユーザー uwi
提出日時 2017-11-24 22:23:48
言語 Java8
(openjdk 1.8.0.222)
結果
AC  
実行時間 90 ms
コード長 3,212 Byte
コンパイル時間 2,742 ms
使用メモリ 32,588 KB
最終ジャッジ日時 2019-10-15 06:07:29

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
0_0_sample_1.txt AC 84 ms
31,804 KB
0_1_sample_2.txt AC 90 ms
30,440 KB
0_2_sample_3.txt AC 89 ms
32,200 KB
1_0.txt AC 84 ms
29,580 KB
1_1.txt AC 84 ms
30,600 KB
1_2.txt AC 81 ms
31,628 KB
1_3.txt AC 81 ms
31,768 KB
1_4.txt AC 81 ms
31,820 KB
1_5.txt AC 81 ms
32,588 KB
1_8.txt AC 79 ms
32,040 KB
1_9.txt AC 81 ms
30,444 KB
1_10.txt AC 81 ms
30,608 KB
2_0.txt AC 78 ms
31,356 KB
2_1.txt AC 82 ms
31,892 KB
2_2.txt AC 80 ms
31,732 KB
2_3.txt AC 79 ms
28,876 KB
2_4.txt AC 81 ms
30,352 KB
3_0.txt AC 80 ms
31,408 KB
3_1.txt AC 79 ms
30,736 KB
3_2.txt AC 79 ms
30,848 KB
3_3.txt AC 80 ms
30,788 KB
3_4.txt AC 79 ms
30,880 KB
4_1.txt AC 80 ms
32,196 KB
4_2.txt AC 80 ms
32,200 KB
4_3.txt AC 83 ms
29,508 KB
5_0.txt AC 82 ms
30,876 KB
5_1.txt AC 81 ms
32,004 KB
99_system_test1.txt AC 82 ms
30,380 KB
99_system_test2.txt AC 80 ms
32,196 KB
99_system_test3.txt AC 81 ms
31,348 KB
99_system_test4.txt AC 81 ms
31,788 KB
テストケース一括ダウンロード

ソースコード

diff #
package contest171124;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class B {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		int n = ni(), x = ni(), a = ni(), b = ni();
		int y = x / a;
		if(x % a != 0){
			y++;
		}
		int z = ((1<<n-1) - x) / b;
		if(((1<<n-1) - x) % b != 0){
			z++;
		}
		out.println(Math.min(y, z));
	}
	
	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
//		Thread t = new Thread(null, null, "~", Runtime.getRuntime().maxMemory()){
//			@Override
//			public void run() {
//				long s = System.currentTimeMillis();
//				solve();
//				out.flush();
//				if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
//			}
//		};
//		t.start();
//		t.join();
	}
	
	public static void main(String[] args) throws Exception { new B().run(); }
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private long[] nal(int n)
	{
		long[] a = new long[n];
		for(int i = 0;i < n;i++)a[i] = nl();
		return a;
	}
	
	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private int[][] nmi(int n, int m) {
		int[][] map = new int[n][];
		for(int i = 0;i < n;i++)map[i] = na(m);
		return map;
	}
	
	private int ni() { return (int)nl(); }
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}
0