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

Обсуждение задачи 1639. Шоколад 2

How did you find the alhorithm, AC-guys?
Послано Komarov Dmitry [Pskov SPI] 12 ноя 2009 01:52
I hate such tasks so much! It's not programming, it's pure math!! So how did you proved the algorithm? I broke my brain truying to solve it!!
Re: How did you find the alhorithm, AC-guys?
Послано melkiy 12 ноя 2009 03:00
You must understand that there are needed as mush cuts as there are little squares in the bar (minus 1).

Imagine that the bar has the shape 1xnm. How many cuts? (n-1), yeah?
Since at the very end all pieces are the little squares, the shape of intermediate cuts doesn't matter, the total cuts count to (n-1).
to melkiy
Послано Komarov Dmitry [Pskov SPI] 12 ноя 2009 11:17
Thank you very much!)
You saved hours of my life!
Re: How did you find the alhorithm, AC-guys?
Послано Mindaugas Kazlauskas 26 июн 2011 07:47
My observation: one cut buys us plus one piece of chocolate, because we can cut only one piece at a time. So, after the first cut we have two pieces, after the second one, we have three pieces, and so on until we have n*m pieces. Now it's easy to see that we only need to check the parity of n*m
Re: How did you find the alhorithm, AC-guys?
Послано ONU_Bullsquid 24 окт 2012 19:38
Is it possible at all?
Re: How did you find the alhorithm, AC-guys?
Послано Anisimov Dmitry (Novosibirsk STU) 15 окт 2014 12:30
There is a winning strategy for the second player is to mirror moves of the first, but if N or M is even, the first player can split it in two halves - the only move cannot be mirrored and wins.
Re: How did you find the alhorithm, AC-guys?
Послано ELDVN 29 окт 2015 23:16
my solution:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iomanip>

#define F first
#define S second
#define ll long long
#define len length()
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define bp(x) __builtin_popcount(x)
#define INF numeric_limits<long long int>::max()
#define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

const int maxn = (int)1e6;
const int mod = (int)1e9 + 7;

using namespace std;

int n,m;

main(){
    scanf("%d%d",&n,&m);
    if(n*m%2==0)
        puts("[:=[first]");
    else
        puts("[second]=:]");






    return 0;
}
Re: How did you find the alhorithm, AC-guys?
Послано zhangweilst 6 дек 2015 09:51
That's the thought. It is conjectured that however youcut it during the process, the total steps are always the same, but I didn't prove it. Now Iget it. Thank you.
Re: How did you find the alhorithm, AC-guys?
Послано kert_sad 8 дек 2017 00:33
mathem much important in programming. U MUST know that, if u dont wants to write indian code