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

Обсуждение задачи 1068. Сумма

what went wrong here? I compiled it in dr.Java and it was okay
Послано Riyad Ahsan Auntor 17 мар 2018 13:09
import java.util.Scanner;
public class Sum{
  public static void main(String args[]){
    Scanner sc= new Scanner(System.in);
    int N, sum=0;
    System.out.print("Enter the value of N:");
    N= sc.nextInt();
    if(N<10000){
      if(N<0){
        for(int x=N; x<=1; x++){
          sum+=x;
        }
      }
        else{
          for(int x=1; x<=N; x++){
            sum+=x;
          }
        }
    }
    System.out.println(sum);
  }
}
Re: what went wrong here? I compiled it in dr.Java and it was okay
Послано Oleg Baskakov 17 мар 2018 16:29
System.out.print("Enter the value of N:");
comment this out, automatic checker doesn't know that this text isn't the part of your answer
Re: what went wrong here? I compiled it in dr.Java and it was okay
Послано Riyad Ahsan Auntor 19 мар 2018 21:32
yup did that too and it still says wrong answer
Re: what went wrong here? I compiled it in dr.Java and it was okay
Послано Oleg Baskakov 20 мар 2018 04:51
Okaaaaay...

if(N<10000){
i assume you wanted to check here if input data is correct, but there's no need to do that, input data is correct by default.
Not to mention that you do it wrong, you check if N is between (-infinity; 9999], while N should be between [-10000; 10000].

Also i think you don't handle the N=0 case correctly, but hopefully you'll figure out why without more hints.