QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#259634#7692. Prof. Fumblemore and the Collatz ConjecturebillytngoAC ✓62ms33144kbJava81.5kb2023-11-21 08:31:402023-11-21 08:31:42

Judging History

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

  • [2023-11-21 08:31:42]
  • 评测
  • 测评结果:AC
  • 用时:62ms
  • 内存:33144kb
  • [2023-11-21 08:31:40]
  • 提交

answer

import java.io.File;
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	
	private static Scanner sc;
	
	private static BigInteger getNum(String s, BigInteger p) {
		// TODO Auto-generated method stub
		int n = s.length();
		
		for(int i=n-1;i>=0;i--) {
			if(s.charAt(i)=='O') {
				p = p.subtract(new BigInteger("1"));
				if(!p.mod(new BigInteger("3")).equals(new BigInteger("0"))){
					return null;
				}
				
				p = p.divide(new BigInteger("3"));
				
				if(p.mod(new BigInteger("2")).equals(new BigInteger("0"))) {
					return null;
				}
			} else {
				p = p.multiply(new BigInteger("2"));
			}
		}
		
		return p;
	}
	
	private static String process(String s) {
		// TODO Auto-generated method stub
		int n = s.length();
		
		if(s.charAt(n-1) == 'E') {
			return "INVALID";
		}
		
		for(int i=0;i<n-1;i++) {
			if(s.charAt(i) == 'O' && s.charAt(i+1) == 'O') {
				return "INVALID";
			}
		}
		
		BigInteger p = new BigInteger("16");
		
		for(int i=4;i<=47;i++) {
			BigInteger m = getNum(s,p); 
			if(m != null) {
				return m.toString();
			}
			
			p = p.multiply(new BigInteger("2"));
		}
		
		return "INVALID";
	}

	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		sc = new Scanner(System.in);
		String s = sc.next();
		String ret = process(s);
		System.out.println(ret);
	}

}

詳細信息

Test #1:

score: 100
Accepted
time: 41ms
memory: 31264kb

input:

EEOEO

output:

12

result:

ok single line: '12'

Test #2:

score: 0
Accepted
time: 38ms
memory: 33036kb

input:

EEOOEO

output:

INVALID

result:

ok single line: 'INVALID'

Test #3:

score: 0
Accepted
time: 55ms
memory: 31244kb

input:

OEOEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

383

result:

ok single line: '383'

Test #4:

score: 0
Accepted
time: 54ms
memory: 31176kb

input:

OEOEEEEEOEOEEEEOEEEEOEOEOEEOEEEO

output:

931

result:

ok single line: '931'

Test #5:

score: 0
Accepted
time: 58ms
memory: 31156kb

input:

OEEOEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

641

result:

ok single line: '641'

Test #6:

score: 0
Accepted
time: 50ms
memory: 31360kb

input:

OEOEEOEEOEEOEEOEEEEOEEEOEOEOEEEEEO

output:

683

result:

ok single line: '683'

Test #7:

score: 0
Accepted
time: 57ms
memory: 31212kb

input:

OEEOEEEOEOEEEEOEEEEOEOEOEEOEEEO

output:

465

result:

ok single line: '465'

Test #8:

score: 0
Accepted
time: 52ms
memory: 31160kb

input:

OEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

481

result:

ok single line: '481'

Test #9:

score: 0
Accepted
time: 45ms
memory: 29956kb

input:

OEEOEOEO

output:

201

result:

ok single line: '201'

Test #10:

score: 0
Accepted
time: 32ms
memory: 31396kb

input:

OEEEEOEEOEOEEEOEOEEOEEEO

output:

133

result:

ok single line: '133'

Test #11:

score: 0
Accepted
time: 49ms
memory: 31188kb

input:

OEOEOEOEEOEEEEEEEEEEOEOEOEEOEEEO

output:

943

result:

ok single line: '943'

Test #12:

score: 0
Accepted
time: 59ms
memory: 31404kb

input:

OEEEOEEO

output:

301

result:

ok single line: '301'

Test #13:

score: 0
Accepted
time: 47ms
memory: 31268kb

input:

OEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

407

result:

ok single line: '407'

Test #14:

score: 0
Accepted
time: 38ms
memory: 33144kb

input:

OEOEOEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

191

result:

ok single line: '191'

Test #15:

score: 0
Accepted
time: 42ms
memory: 29948kb

input:

OEEEOEO

output:

605

result:

ok single line: '605'

Test #16:

score: 0
Accepted
time: 62ms
memory: 31172kb

input:

OEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

431

result:

ok single line: '431'

Test #17:

score: 0
Accepted
time: 41ms
memory: 30004kb

input:

OEOEEEOEEEOEOEOEEEOEEEEOEOEEEOEOEEOEEEO

output:

563

result:

ok single line: '563'

Test #18:

score: 0
Accepted
time: 61ms
memory: 29928kb

input:

OEEOEEEEEOEEOEEEO

output:

241

result:

ok single line: '241'

Test #19:

score: 0
Accepted
time: 50ms
memory: 29924kb

input:

OEEEOEEEEOEOEEEOEOEEOEEEO

output:

269

result:

ok single line: '269'

Test #20:

score: 0
Accepted
time: 53ms
memory: 31280kb

input:

EEOEOEOEEOEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

540

result:

ok single line: '540'

Test #21:

score: 0
Accepted
time: 47ms
memory: 29916kb

input:

OEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

575

result:

ok single line: '575'

Test #22:

score: 0
Accepted
time: 40ms
memory: 30048kb

input:

EEOEEOEOEEEEEOEOEOEEEEEO

output:

868

result:

ok single line: '868'

Test #23:

score: 0
Accepted
time: 45ms
memory: 29896kb

input:

OEOEOEO

output:

26512143

result:

ok single line: '26512143'

Test #24:

score: 0
Accepted
time: 55ms
memory: 30116kb

input:

OEOEOEEO

output:

13256071

result:

ok single line: '13256071'

Test #25:

score: 0
Accepted
time: 46ms
memory: 31192kb

input:

EEO

output:

20

result:

ok single line: '20'

Test #26:

score: 0
Accepted
time: 49ms
memory: 31164kb

input:

EOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEE

output:

INVALID

result:

ok single line: 'INVALID'

Test #27:

score: 0
Accepted
time: 49ms
memory: 29860kb

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEO

output:

43980465111040

result:

ok single line: '43980465111040'

Test #28:

score: 0
Accepted
time: 45ms
memory: 31172kb

input:

EEEEEEEEEEOEEEOEEEEOEOEEOEEEEEOEEEEEEEOEEOEEEEEEEO

output:

7321693729792

result:

ok single line: '7321693729792'

Test #29:

score: 0
Accepted
time: 35ms
memory: 31200kb

input:

EEEOEEEOEEOEEEEEOEEEEEEEOEEEEEEEEEEEEEEEEOEEEEEO

output:

1028529777000

result:

ok single line: '1028529777000'