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

Обсуждение задачи 1214. Странная процедура

My solution here :) in 7 lines!!!!
Послано Tolyan_PP 4 июн 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)
Послано Виктор Крупко 4 июн 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
Послано jedimastex 27 дек 2005 16:01
no message
:)))
Послано AndrewSt 29 дек 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
Послано void off() 2 янв 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}
Послано wyyyl 10 авг 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}
Послано hailoc12 23 сен 2006 21:28
How can you find this solution?
Re: C++ forever:)) so my solution's here in 5 lines
Послано ecbtnrt 24 сен 2006 10:03
Very good!
Re: C++ forever:)) so my solution's here in 5 lines
Послано Azazel 24 мар 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
Послано alexutz_mircescu 26 окт 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
Послано jagatsastry 5 дек 2007 23:03
How did you people come out with this?
Re: Usual source :b
Послано TIA (Lyceum #165) 8 янв 2008 16:37
jagatsastry писал(a) 5 декабря 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
Послано lomereiter 19 мар 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!!!!
Послано Madhav 15 июн 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!
Послано mberdyshev 1 сен 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
Послано mouse_wireless2 31 янв 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