ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1196. Экзамен по истории

wa1
Послано Iliya (Java) 26 окт 2008 05:10
What's wrong in my program?(It passed all my tests)
import java.io.*;

public class Task1196 {
    public static void main(String[] args) throws IOException {
        StreamTokenizer in = new StreamTokenizer(
                new InputStreamReader(
                        System.in
                )
        );
        in.nextToken();
        int n = (int) in.nval;
        long prep[] = new long[n];
        for(int i=0;i<n;i++){
            in.nextToken();
            prep[i]=(long)in.nval;
        }
        long ans = 0;
        in.nextToken();
        long m =(long)in.nval;
        for(int i=0;i<m;i++){
            in.nextToken();
            if(binSearch(prep,(long)in.nval)){
                ans++;
            }
        }
        System.out.print(ans);
    }
    public static boolean binSearch(long[] prep,long date){
        int down=0;
        int up = prep.length-1;
        int m;
        while(true){
            m= (up+down)/2;
            if(prep[m]>date){
                up=m-1;
            }else if(prep[m]<date){
                down=m+1;
            }else{
                return true;
            }
            if(down>up){
                return false;
            }
        }
    }
}
Re: wa1
Послано [SPbSU ITMO] WiNGeR 26 окт 2008 05:14
There are some problems with Java now..
Every program in Java gets wa1 (

Edited by author 26.10.2008 05:20
Re: wa1
Послано Ilya (Vologda SPU) 27 окт 2009 21:49
Really? It's sux >_<

I get known that there is another scanner required:
Scanner scanner = new Scanner(System.in, "ISO-8859-1");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, "ISO-8859-1"));
PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out, "ISO-8859-1"));

It's written here:
http://acm.timus.ru/help.aspx?topic=java (look at the bottom of the page)

I just like to know WHERE and HOW I should paste this new scanner into my program in order to it behave!


Edited by author 29.10.2009 00:44
Re: wa1 LK at the OUTPUT explain
Послано yangdong 21 окт 2010 13:31
"Output the number of dates in the student's that are also contained in Professor's list."
you needn't count the time it appears ...
count the amount of appear numbers in list 2 is just OK...
Re: wa1
Послано [PNTU]Sergiy D 22 апр 2011 21:59
On C++ the same problem now.
Re: wa1
Послано Nafania 21 окт 2011 15:37
yangdong is right.

Hint: use list or set for first dates and you will be happy. ^_^

P.S.: Sorry for my English :)

Edited by author 21.10.2011 15:39