QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#259564#7695. Double UpbillytngoRE 94ms42700kbJava81.4kb2023-11-21 01:40:052023-11-21 01:40:06

Judging History

你现在查看的是最新测评结果

  • [2023-11-21 01:40:06]
  • 评测
  • 测评结果:RE
  • 用时:94ms
  • 内存:42700kb
  • [2023-11-21 01:40:05]
  • 提交

answer

import java.io.File;
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.Set;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

public class Main {
	
	private static Scanner sc;
	
	private static final int INF = 1000000000;
	
	private static int getK(int v) {
		// TODO Auto-generated method stub
		int ret = 0;
		while(v > 1) {
			ret++;
			v/=2;
		}
		return ret;
	}
	
	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> P = new ArrayList<Integer>();
		for(int i=0;i<n;i++) {
			int v = getK(sc.nextInt()); 
			P.add(v);
		}
		
		while(P.size()>1) {
			List<Integer> _P = new ArrayList<Integer>();
			int m = INF;
			for(int i=0;i<P.size();i++) {
				m = Math.min(m, P.get(i));
			}
			for(int i=0;i<P.size();i++) {
				if(i+1<P.size() && P.get(i).equals(m) && P.get(i+1).equals(m)) {
					_P.add(P.get(i)+1);
					i++;
					continue;
				}
				
				if(P.get(i).equals(m)) {
					continue;
				}
				
				_P.add(P.get(i));
			}
			P = _P;
		}
		
		BigInteger ret = new BigInteger("1");
		for(int i=0;i<P.get(0);i++) {
			ret = ret.multiply(new BigInteger("2"));
		}
		
		System.out.println(ret);
	}

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 50ms
memory: 38392kb

input:

5
4 2 2 1 8

output:

16

result:

ok single line: '16'

Test #2:

score: 0
Accepted
time: 94ms
memory: 42700kb

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

512

result:

ok single line: '512'

Test #3:

score: -100
Runtime Error

input:

1000
1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650...

output:


result: