QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#259566 | #7695. Double Up | billytngo | AC ✓ | 128ms | 75704kb | Java8 | 1.4kb | 2023-11-21 01:43:30 | 2023-11-21 01:43:31 |
Judging History
answer
import java.io.File;
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
public class Main {
private static Scanner sc;
private static final int INF = 1000000000;
private static int getK(BigInteger v) {
// TODO Auto-generated method stub
int ret = 0;
while(v.compareTo(new BigInteger("1")) > 0) {
ret++;
v = v.divide(new BigInteger("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++) {
String s = sc.next();
int v = getK(new BigInteger(s));
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: 51ms
memory: 44064kb
input:
5 4 2 2 1 8
output:
16
result:
ok single line: '16'
Test #2:
score: 0
Accepted
time: 77ms
memory: 45580kb
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: 0
Accepted
time: 128ms
memory: 75704kb
input:
1000 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650...
output:
649037107316853453566312041152512
result:
ok single line: '649037107316853453566312041152512'
Test #4:
score: 0
Accepted
time: 58ms
memory: 43352kb
input:
1 1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 49ms
memory: 43812kb
input:
1 2
output:
2
result:
ok single line: '2'
Test #6:
score: 0
Accepted
time: 43ms
memory: 43640kb
input:
1 4294967296
output:
4294967296
result:
ok single line: '4294967296'
Test #7:
score: 0
Accepted
time: 52ms
memory: 43552kb
input:
1 18446744073709551616
output:
18446744073709551616
result:
ok single line: '18446744073709551616'
Test #8:
score: 0
Accepted
time: 40ms
memory: 43352kb
input:
1 1267650600228229401496703205376
output:
1267650600228229401496703205376
result:
ok single line: '1267650600228229401496703205376'
Test #9:
score: 0
Accepted
time: 89ms
memory: 49820kb
input:
384 18014398509481984 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 10737418...
output:
618970019642690137449562112
result:
ok single line: '618970019642690137449562112'
Test #10:
score: 0
Accepted
time: 86ms
memory: 51768kb
input:
430 36893488147419103232 128 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248...
output:
158456325028528675187087900672
result:
ok single line: '158456325028528675187087900672'
Test #11:
score: 0
Accepted
time: 90ms
memory: 52028kb
input:
527 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 10...
output:
158456325028528675187087900672
result:
ok single line: '158456325028528675187087900672'
Test #12:
score: 0
Accepted
time: 102ms
memory: 54552kb
input:
809 1073741824 77371252455336267181195264 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 20...
output:
19807040628566084398385987584
result:
ok single line: '19807040628566084398385987584'
Test #13:
score: 0
Accepted
time: 78ms
memory: 46396kb
input:
435 618970019642690137449562112 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 128 128 128 128 128 128 128 128 128 128 128 128 128 ...
output:
316912650057057350374175801344
result:
ok single line: '316912650057057350374175801344'
Test #14:
score: 0
Accepted
time: 112ms
memory: 58568kb
input:
857 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 43...
output:
1267650600228229401496703205376
result:
ok single line: '1267650600228229401496703205376'
Test #15:
score: 0
Accepted
time: 120ms
memory: 64276kb
input:
765 17592186044416 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 241785163922925834941...
output:
1237940039285380274899124224
result:
ok single line: '1237940039285380274899124224'
Test #16:
score: 0
Accepted
time: 78ms
memory: 46176kb
input:
122 2097152 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 ...
output:
10141204801825835211973625643008
result:
ok single line: '10141204801825835211973625643008'
Test #17:
score: 0
Accepted
time: 110ms
memory: 55180kb
input:
491 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 562949953421312 9444732965739290427392 9444732965739290427392 9444732965739290427392 9444732965739290427392 9444732965739290427392 94447329657392904273...
output:
1267650600228229401496703205376
result:
ok single line: '1267650600228229401496703205376'
Test #18:
score: 0
Accepted
time: 78ms
memory: 47192kb
input:
164 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 5497558138...
output:
20282409603651670423947251286016
result:
ok single line: '20282409603651670423947251286016'