ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1723. Sandro's Book

How can my program get AC even it returns wrong answer for the first test?
Posted by JAVATAR 5 Mar 2012 02:13
Hello,
How can my program get AC even it returns wrong answer for the first test?

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;


public class SandrosBook {

    public static void main(String args[]) throws IOException{

        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

        PrintWriter out=new PrintWriter(System.out);

        int[] a=new int[26];

        String s=br.readLine();
        int i=1;
        int start=0,end=0;
        start=s.charAt(0)-97;
        int max=0;




        while(i<s.length()){
            char c=s.charAt(i);
            a[(int)c-97]++;
            i++;
        }

        int k=0;
      for(int ii=0;ii<26;ii++){
           if(a[ii]>max)
           {
           max=a[ii];
           k=ii;
           }
        }

           k=k+97;

        System.out.println((char)k);
        out.flush();
    }

}
Re: How can my program get AC even it returns wrong answer for the first test?
Posted by Erop [USU] 9 Mar 2012 14:04
try test:
b

right answer "b", but you output "a"

Edited by author 09.03.2012 14:09
Re: How can my program get AC even it returns wrong answer for the first test?
Posted by [TH0212]1112497[HT] 16 Oct 2012 07:38
my son fail