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

Обсуждение задачи 1082. Иванушка-дурачок

can anyone write shorter solotion than mine ?
Послано Saber 6 фев 2003 16:12
here is mine :
  var
    n,i   : longint;
  begin
    readln (n);
    for i := 1 to n do
      write (i,' ');
  end.
Many people knows that, don't be so......
Послано Lucky 6 фев 2003 16:30
DOnt be selfish!
Послано Locomotive 7 фев 2003 09:43
U can use integer instead of longint and also write for loop, in just
one line!!!
anyhow...
solotion has no meaning!
you should say: solution...
Your Friend
Aidin_n7
Re: can anyone write shorter solotion than mine ?
Послано Spiteful Berkut 23 апр 2008 12:08
program tm_1082;
var
  N: 0..1000;
begin
  Readln(N);
  while boolean(n) do
    begin
      write(-N,' ');
      Dec(N)
    end;
end.
Re: can anyone write shorter solotion than mine ?
Послано yuhc 10 июн 2009 18:36
var n,i :integer;
begin
readln(n);
for i := 1 to n do write(i,' ');
end.
Re: can anyone write shorter solotion than mine ?
Послано Alexandr Opara 18 июн 2009 21:18
#include <stdio.h>
void main(){
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++) printf("%d ",i); }
Re: can anyone write shorter solotion than mine ?
Послано AXIS ZULU 20 фев 2010 17:37
NOT shorter BUT better
i can give you a hint...
ok
we start with 1
if you input 1->ok
if you input 1->ok
if you input 3->ok
if you input 7(3*2+1)->ok
if you input 19(7*2+3*2)->ok
if you input 52(19*2+7*2)->ok
...............................
have you got it....
if not stat with 1;
read n
a=1;
b=3;
n--;
write b
a=b;
b=a+b*2;
for 1->n
{
write b*2+a*2
}
:)
not shorter but better:D
Re: can anyone write shorter solotion than mine ?
Послано Petrenuk 16 сен 2010 04:35
#include<cstdio>
int main(){int n;scanf("%d",&n);for(;n;n--)printf("%d ",-n);}

Edited by author 16.09.2010 04:37
Re: can anyone write shorter solotion than mine ?
Послано brute11k 23 окт 2010 21:18
#include<stdio.h>
main(){int n;scanf("%d",&n);while(n*printf("%d ",-n--));}

Edited by author 23.10.2010 21:23

Edited by author 23.10.2010 22:24
Re: can anyone write shorter solotion than mine ?
Послано allocator 28 июн 2011 02:24
Use <cstdio> =)
Re: can anyone write shorter solotion than mine ?
Послано Sasha Bar [TNU] 28 июн 2011 03:38
OMG!
Re: can anyone write shorter solotion than mine ?
Послано Granfalloner 12 фев 2016 12:30
brute11k писал(a) 23 октября 2010 21:18
#include<stdio.h>
main(){int n;scanf("%d",&n);while(n*printf("%d ",-n--));}

Concise, but, strictly speaking, is not guaranteed to work properly - as it is with all expressions of kind a[i] = i++. E.g., clang gives error - "unsequenced modification and access to 'n'". The problem here is that in C/C++ all side-effects of arguments to functions are computed *before* function call. To fix this, we need to introduce a sequence point (https://en.wikipedia.org/wiki/Sequence_point) - e.g., comma:

#include<stdio.h>
main(){int n;scanf("%d",&n);while(n*printf("%d ",-n),--n);}


Edited by author 12.02.2016 12:31
Re: can anyone write shorter solution than mine ?
Послано Horse in coat 28 фев 2016 00:44
print(*list(int(x)+1 for x in range(int(input()))))
can anyone shorter?

Edited by author 28.02.2016 00:45
Re: can anyone write shorter solution than mine ?
Послано Andrey Yamnikov 17 мар 2018 00:47
41 bytes (Python 2.7)

print ' '.join(map(str,range(int(input()))))

27 bytes (Python 3.6)

print(*range(int(input())))

Edited by author 17.03.2018 00:52