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 1082. Gaby Ivanushka

can anyone write shorter solotion than mine ?
Posted by Saber 6 Feb 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......
Posted by Lucky 6 Feb 2003 16:30
DOnt be selfish!
Posted by Locomotive 7 Feb 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 ?
Posted by Spiteful Berkut 23 Apr 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 ?
Posted by yuhc 10 Jun 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 ?
Posted by Alexandr Opara 18 Jun 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 ?
Posted by AXIS ZULU 20 Feb 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 ?
Posted by Petrenuk 16 Sep 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 ?
Posted by brute11k 23 Oct 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 ?
Posted by allocator 28 Jun 2011 02:24
Use <cstdio> =)
Re: can anyone write shorter solotion than mine ?
Posted by Sasha Bar [TNU] 28 Jun 2011 03:38
OMG!
Re: can anyone write shorter solotion than mine ?
Posted by Granfalloner 12 Feb 2016 12:30
brute11k wrote 23 October 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 ?
Posted by Horse in coat 28 Feb 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 ?
Posted by Andrey Yamnikov 17 Mar 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