My solution here :) in 7 lines!!!!
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)
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.
:)))
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
#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}
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
#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
How did you people come out with this?
Re: Usual source :b
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
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!
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
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