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 1214. Strange Procedure

My solution here :) in 7 lines!!!!
Posted by Tolyan_PP 4 Jun 2005 00:09
var x,y:longint;
Procedure out(x,y:longint);
begin writeln(x,' ',y);halt;end;
begin readln(x,y);
if (x=y)or(x<0)or(y<0) then out(x,y);
if ((x mod 2= 0)and(y mod 2 = 0))or((x mod 2<>0)and(y mod 2<>0)) then out(x,y);out(y,x);end.
You could write down in one line(13)
Posted by Виктор Крупко 4 Jun 2005 01:52
var
x,y:longint;
Procedure out(x,y:longint);
begin
  writeln(x,' ',y);
  halt;
end;
begin
readln(x,y);
if (x=y)or(x<0)or(y<0) then out(x,y);
if ((x mod 2= 0)and(y mod 2 = 0))or((x mod 2<>0)and(y mod 2<>0)) then out(x,y);out(y,x);
end.
no subject
Posted by jedimastex 27 Dec 2005 16:01
no message
:)))
Posted by AndrewSt 29 Dec 2005 23:14
I do not like your decision. It very complex. See on my.
Forgive for my English.

program _1214_strange_procedure;
var
  X, Y: longint;
begin
  Readln(X,Y);
  if (X<0)or(Y<0)then  writeln(X,' ',Y)
  else
    if (X+Y)mod 2 = 0 then writeln(X,' ',Y)
    else  writeln(Y,' ',X);
end.
C++ forever:)) so my solution's here in 5 lines
Posted by void off() 2 Jan 2006 20:05
#include <iostream.h>
void main()
{int x,y;
cin>>x>>y;
cout<<(x<0)||(y<0)||((x+y)%2==0)?x:y<<' '<<(x<0)||(y<0)||((x+y)%2==0)?y:x;}
Re: You could write down in one line(13) -- More simple {simpler}
Posted by wyyyl 10 Aug 2006 16:08
//you can be more simple, no procedures
var
x,y:longint;
begin
readln(x,y);
if (x=y) or (x<0) or (y<0) or (odd(x)=odd(y)) then writeln(x,' ',y)
else writeln(y,' ',x);
end.
//7 lines

Edited by author 10.08.2006 16:10

Edited by author 10.08.2006 16:10
Re: You could write down in one line(13) -- More simple {simpler}
Posted by hailoc12 23 Sep 2006 21:28
How can you find this solution?
Re: C++ forever:)) so my solution's here in 5 lines
Posted by ecbtnrt 24 Sep 2006 10:03
Very good!
Re: C++ forever:)) so my solution's here in 5 lines
Posted by Azazel 24 Mar 2007 06:32
var x,y:longint;
begin
 read(x,y);
 if ((x+y) mod 2=0)or(x<=0)or(y<=0) then write(x,' ',y)
                                    else write(y,' ',x);
end.

P.s.6 lines!:p
P.p.s.It's so easy..Just try in some test.
Usual source :b
Posted by alexutz_mircescu 26 Oct 2007 23:36
#include <stdio.h>
#include <math.h>

long x, y;

int main() {
    #ifndef ONLINE_JUDGE
    freopen("1214.in", "r", stdin);
    freopen("1214.out", "w", stdout);
    #endif
    scanf("%ld%ld", &x, &y);
    if ((x + y) % 2 == 0 || x <=0 || y <= 0) printf("%ld %ld", x, y);
    else printf("%ld %ld", y, x);
    return 0;
}
p.s It's too easy
Re: Usual source :b
Posted by jagatsastry 5 Dec 2007 23:03
How did you people come out with this?
Re: Usual source :b
Posted by TIA (Lyceum #165) 8 Jan 2008 16:37
jagatsastry wrote 5 December 2007 23:03
How did you people come out with this?
Just try some test with odd/even and positive/negative x and y
Re: Usual source :b
Posted by lomereiter 19 Mar 2008 19:36
void_off(), nice =) C++ 4ever =)))

#include <iostream.h>
main(){int x,y;cin>>x>>y;if(x>0&&y>0&&(x+y)%2)x^=y^=x^=y;cout<<x<<" "<<y;}
Re: My solution here :) in 7 lines!!!!
Posted by Madhav 15 Jun 2008 15:46
My solution is in just 6 lines.
#include<iostream>
using namespace std;
int main(){
        long x,y;
        cin>>x>>y;
        if(x>0&&y>0)
                if((x+y)%2)
                        swap(x,y);
        cout<<x<<" "<<y<<endl;
        return 0;
}
4 lines!
Posted by mberdyshev 1 Sep 2016 02:41
x, y = map(int, input().split())
if x <= 0 or y <= 0 or (x + y) % 2 == 0:
    print(x, y)
else: print(y, x)
Haskell solution in 3 lines and 129 bytes
Posted by mouse_wireless2 31 Jan 2018 02:54
main=do
 v<-fmap((map read).words)getLine
 putStrLn$unwords$map show$if((sum v) `mod` 2 == 0)||(any(<=0)v)then v else reverse v