标签:style blog http java color strong
zoj ozojo ozoojoo oozoojoooo zooj ozojo oooozojo zojoooo
Accepted Accepted Accepted Accepted Accepted Accepted Wrong Answer Wrong Answer
分析:
AC的情况: a个o + z + b个o +j + c个o
c=a*b,且b>=1
(o^a)z(o^b)j(o^c) c=a*b,且b>=1
z,j都只有一个。且j在z之后出现,b>=1可以保证j在z之后出现。
import java.util.*;
public class Main {
public static boolean check(String s)
{
int p=0,q=0,zp,jp,a,b,c;
p=s.indexOf("z");
q=s.lastIndexOf("z");
if(p!=q)
return false;
if(p==-1)
return false;
zp=p;
p=s.indexOf("j");
q=s.lastIndexOf("j");
if(p!=q)
return false;
if(p==-1)
return false;
jp=p;
a=zp;
b=jp-a-1;
c=s.length()-jp-1;
if((c==a*b) && (b>=1))
return true;
return false;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
String t;
boolean b;
Scanner scanneer = new Scanner(System.in);
while (scanneer.hasNext() )
{
t=scanneer.nextLine();
b=check(t);
if(b)
System.out.println("Accepted");
else
System.out.println("Wrong Answer");
}
}
}
/**************************************************************
Problem: 1006
User: caiyunfree20
Language: Java
Result: Accepted
Time:930 ms
Memory:27016 kb
****************************************************************/标签:style blog http java color strong
原文地址:http://blog.csdn.net/caiyunfreedom/article/details/36699949