A question of details in the solution at the end of this post of the question is asked by me at MSE.

Nowadays, I learnt from Liu Ben a question asked in the interview of ENS.

Assume $m,n$ are two coprime odd numbers, consider the interval $[0,mn]$. We cut the interval by $m,2m,\ldots,(n-1)m$ and $n, 2n,\ldots, (m-1)n$ into $m+n-1$ pieces of small intervals. And we color them from left to right by black-and-white periodically and black first. The question is to show $$(\textrm{the length of black})-(\textrm{the length of white})=1$$

For example, if $m=3,n=5$, $$\begin{array}{c*{31}}0 &&&&&& 3 &&&&&& 6 &&&&&& 9 &&&&&& 12 &&&&&& 15 \\ \mid & \blacksquare && \blacksquare && \blacksquare &\mid & \square && \square & \mid  & \blacksquare & \mid  & \square&& \square&& \square &\mid & \blacksquare &\mid & \square&& \square&\mid & \blacksquare&& \blacksquare&& \blacksquare & \mid  \\ 0 &&&&&&&&&& 5 &&&&&&&&&& 10 &&&&&&&&&& 15\end{array} $$The length of black is $8$ and the length of white is $7$.

The problem seems to be elementary at the first sight. But after a period of thinking, one find it is hard to deal with. Here is Liu Ben's Original answer, I fulfill details to read more easily,

The number of cuts before $x$ is $\lfloor \frac{x-1}{n}\rfloor+\lfloor \frac{x-1}{m}\rfloor$, so $$(-1)^{\lfloor \frac{x-1}{n}\rfloor+\lfloor \frac{x-1}{m}\rfloor}=\begin{cases} 1 & \textrm{$[x-1,x]$ is colored by black }\\ -1 & \textrm{$[x-1,x]$ is colored by white } \end{cases}$$Thus it is equivlent to show that $\sum_{x=0}^{mn-1} (-1)^{\lfloor \frac{x}{n}\rfloor+\lfloor \frac{x}{m}\rfloor}=1$, and we have know that $(-1)^{m+n}=1, (-1)^0=1$, so  it is equivlent to show that $$\sum_{x=1}^{mn} (-1)^{\lfloor \frac{x}{n}\rfloor+\lfloor \frac{x}{m}\rfloor}=1$$Now we need some identity to expand the expression $(-1)^{\lfloor \frac{x}{n}\rfloor}$,

$$\begin{array}{rll} (-1)^{\lfloor x \rfloor}& = (-1)^{\lfloor x\rfloor}-1+1 \\ & =1+ 2\left(\sum_{n=0}^{\lfloor x\rfloor}(-1)^{n}\right)= 1+ 2\left(\sum_{n\leq x}(-1)^{n}\right)\end{array}$$

So

$$\begin{array}{rll}&\quad  \sum_{x=1}^{mn} (-1)^{\lfloor \frac{x}{n}\rfloor+\lfloor \frac{x}{m}\rfloor} \\  & =\sum_{x=1}^{mn} \left(1+2\left(\sum_{k\leq x/n} (-1)^k \right)\right)\left(1+2\left(\sum_{k\leq x/m} (-1)^k\right)\right) \\ & = mn+2\underbrace{\sum_{x=1}^{mn}\sum_{k\leq x/n} (-1)^k}_{:=A}+2\underbrace{\sum_{x=1}^{mn}\sum_{k\leq x/m} (-1)^k}_{:=B}+4\sum_{x=1}^{mn}\left(\sum_{k\leq x/n} (-1)^k\right)\left(\sum_{h\leq x/m} (-1)^h\right)\end{array}$$

Firstly, we calculate $A$,

$$\begin{array}{rll}A & =\sum_{x=1}^{mn}\sum_{k\leq x/n} (-1)^k \\ & = \sum_{k=1}^m \#\{x\geq nk: x=1,\ldots,mn\}(-1)^k  \\ & =\sum_{k=0}^m n(m-k)(-1)^k \\ & = n\sum_{k=0}^m k(-1)^k\\& =-n\frac{m+1}{2}\end{array}$$

Similarly, $B=-m\frac{n+1}{2}$, therefore it remains to show

$$\sum_{x=1}^{mn}\left(\sum_{k\leq x/n} (-1)^k\right)\left(\sum_{h\leq x/m} (-1)^h\right)=\frac{(m+1)(n+1)}{4}$$

Let's compute !

$$\begin{array}{rll}\sum_{x=1}^{mn}\left(\sum_{k\leq x/n} (-1)^k\right)\left(\sum_{h\leq x/m} (-1)^h\right) & =\sum_{k=0}^{m}\sum_{h=0}^n\#\{x\geq \max (nk,mh), x=1,\ldots,mn\}(-1)^{k+h}\\ & =\sum_{k=0}^{m}\sum_{h=0}^n(mn- \max(nk,mh))(-1)^{k+h} \\ & =\sum_{k=0}^{m}\sum_{h=0}^n \max(nk,mh)(-1)^{k+h} \\ & =\sum_{k=0}^{m}\sum_{h=0}^n \frac{1}{2}(nk+mh+\left|nk-mh\right|)(-1)^{k+h}  \\ &= \frac{1}{2}\sum_{k=0}^{m}\sum_{h=0}^n \left|nk-mh\right|(-1)^{k+h} \\ & = \frac{mn}{2}\sum_{k=0}^m\sum_{h=0}^n\left|\frac{k}{m}-\frac{h}{n}\right|(-1)^{k+h}\end{array}$$

So it reduces to show $\sum_{k=0}^m\sum_{h=0}^n\left|\frac{k}{m}-\frac{h}{n}\right|(-1)^{k+h}=0$. We need some tools to calculate, consider the function $f$ with peroid $2$ and $f(x)=|x|$ for $x\in [-1,1]$, then the Fourier series of $f$ is $$f=\sum_{\ell \in \mathbb{Z}} a_{\ell} \mathrm{e}^{\frac{2\pi i \ell x}{2}}\qquad a_{\ell} =\frac{1}{2}\int_{-1}^1 |x| \mathrm{e}^{\frac{2\pi i \ell x}{2}}\textrm{d}x=\begin{cases}\frac{1}{2} & n=0 \\ -\frac{2}{\pi^2 n^2} & n\textrm{is odd} \\ 0 & n\neq 0\textrm{is even}\end{cases}$$

In other word, we have

$$x\in [-1,1]\Rightarrow \frac{1}{4}-\frac{|x|}{2}=\sum_{\ell \textrm{odd}} \frac{1}{\pi^2 \ell ^2}\mathrm{e}^{2\pi i \ell x}$$

Now, continuous

$$\begin{array}{rll} \frac{mn}{2}\sum_{k=0}^m\sum_{h=0}^n\left|\frac{k}{m}-\frac{h}{n}\right|(-1)^{k+h} & = mn \sum_{k=0}^m\sum_{h=0}^n\frac{\left|\frac{k}{m}-\frac{h}{n}\right|}{2}(-1)^{k+h} \\ & =mn \sum_{k=0}^m\sum_{h=0}^n\bigg(\frac{1}{4}-\frac{\left|\frac{k}{m}-\frac{h}{n}\right|(-1)^{k+h}}{2} \bigg) \\ & = \sum_{k=0}^m \sum_{h=0}^n \sum_{\ell\textrm{odd}} \frac{1}{\pi^2 \ell ^2} \mathrm{e}^{\frac{2\pi i}{2}\cdot \ell \left(\frac{k}{m}-\frac{h}{n}\right)}  \\  & =mn\sum_{\ell \textrm{odd}} \frac{1}{\pi^2 \ell^2 }\left(\sum_{k=0}^m (-1)^k\mathrm{e}^{\frac{2 \pi i  \ell k}{2 m }}\right)\left(\sum_{h=0}^n (-1)^h\mathrm{e}^{-\frac{2 \pi i  \ell h}{2 n }}\right)\end{array}$$

It reduces to the case of the summation of geometry series, we have

$$\sum_{k=0}^m (-1)^k\mathrm{e}^{\frac{2 \pi i  \ell k}{2 m }}=\begin{cases}-1& m\nmid \ell \\ -1+m & m\mid \ell \end{cases}\qquad \sum_{h=0}^n (-1)^h\mathrm{e}^{-\frac{2 \pi i  \ell h}{2 n }} = \begin{cases}-1& n\nmid \ell \\ -1+n & n\mid \ell \end{cases}$$

Now we can deduct the result,

$$\begin{array}{rll} & \quad mn\sum_{\ell \textrm{odd}} \frac{1}{\pi^2 \ell^2 }\left(\sum_{k=0}^m (-1)^k\mathrm{e}^{\frac{2 \pi i  \ell k}{2 m }}\right)\left(\sum_{h=0}^n (-1)^h\mathrm{e}^{-\frac{2 \pi i  \ell h}{2 n }}\right) \\ & =mn\sum_{\ell \textrm{odd}} \frac{1}{\pi^2 \ell^2 } - mn\sum_{\begin{subarray}{l}\ell \textrm{odd}\\ m|\ell \end{subarray}} \frac{m}{\pi^2 \ell^2} - mn\sum_{\begin{subarray}{l}\ell \textrm{odd}\\ n|\ell \end{subarray}} \frac{n}{\pi^2 \ell^2} + mn\sum_{\begin{subarray}{l}\ell \textrm{odd}\\ n|\ell \\ m|\ell \end{subarray}} \frac{nm}{\pi^2 \ell^2} \\ & = mn\sum_{\ell \textrm{odd}} \frac{1}{\pi^2 \ell^2 } - n\sum_{\begin{subarray}{l}\ell \textrm{odd}\\ m|\ell \end{subarray}} \frac{1}{\pi^2 (\ell/m)^2} - m\sum_{\begin{subarray}{l}\ell \textrm{odd}\\ n|\ell \end{subarray}} \frac{1}{\pi^2 (\ell/n)^2} + \sum_{\begin{subarray}{l}\ell \textrm{odd}\\ nm\mid \ell \end{subarray}} \frac{1}{\pi^2 (\ell/mn)^2} \\ & =(m-1)(n-1) \sum_{\ell \textrm{odd}} \frac{1}{\pi^2 \ell^2 }  =\frac{(m-1)(n-1)}{4}\end{array}$$

The proof is complete. $\square$

If we reflect the process above carefully, we will find that the trick of exponential sums is useful in the domain of combinatorics involving number theory. It is powerful but not too beutiful. The amazing point is that in the process of counting number, $\pi$ can occur, even it will be cancelled finally.

Some days after, Liu Ben gives a new answer which uses Fourier analysis, it is more elegant than the above, and I fulfill details to read more easily,

Actually, as above it reduces to show $$\int_0^{mn}(-1)^{\lfloor \frac{x}{n}\rfloor+\lfloor \frac{x}{m}\rfloor}\textrm{d}x=\int_0^{mn}(-1)^{\lfloor \frac{x}{n}\rfloor}\overline{(-1)^{\lfloor \frac{x}{m}\rfloor}}\textrm{d}x=1$$Conside $f(x)=(-1)^{\lfloor x\rfloor}$ as a function of period $2$, one can calculate its Fourier expansion$$f(x)=\frac{2}{\pi i}\sum_{\ell\textrm{odd}}\frac{1}{\ell} \mathrm{e}^{\frac{2\pi i \ell x}{2}}$$So $$\begin{array}{rll}\int_0^{mn}(-1)^{\lfloor \frac{x}{n}\rfloor}\overline{(-1)^{\lfloor \frac{x}{m}\rfloor}}\textrm{d}x& =\int_{0}^{mn}f(x/n)\overline{f(x/m)}\textrm{d}x \\ & =mn\int_0^1 f(ny)\overline{f(my)}\textrm{d}y \\ & = \frac{4 mn}{\pi^2}\sum_{\begin{subarray}{l}r,s  \textrm{odd} \\ mr=ns\end{subarray}}\frac{1}{rs} \\ & =  \frac{4 mn}{\pi^2}\sum_{\begin{subarray}{l}r,s  \textrm{odd} \\ r=tn,s=tm\end{subarray}}\frac{1}{rs} \\ &  =\frac{4}{\pi^2}\sum_{t\textrm{odd}}\frac{1}{t^2}=1\end{array} $$The proof is complete. $\square$

To complete this post, I want to give my answer of this problem. I think this answer is the most ingenious one. This is a proof without words as following.

When I heared the problem, I had no papers and pen to use. After thinking over brokenly, I came up the answer above one day after. And one can easily find that in the case of one of $m,n$ is even, then the difference between black and white vanish, and when $m,n$ are odd generally, the difference is $(m,n)$.

Ackowlegement

I want to thank Liu Ben for his nice presentation of question and answer. And congratulation to his addmision by ENS.

An interesting combinational problem的更多相关文章

  1. hdu 2426 Interesting Housing Problem 最大权匹配KM算法

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2426 For any school, it is hard to find a feasible ac ...

  2. HDU 2426 Interesting Housing Problem (最大权完美匹配)【KM】

    <题目链接> 题目大意: 学校里有n个学生和m个公寓房间,每个学生对一些房间有一些打分,如果分数为正,说明学生喜欢这个房间,若为0,对这个房间保持中立,若为负,则不喜欢这个房间.学生不会住 ...

  3. HDU 2426 Interesting Housing Problem(二分图最佳匹配)

    http://acm.hdu.edu.cn/showproblem.php?pid=2426 题意:每n个学生和m个房间,现在要为每个学生安排一个房间居住,每个学生对于一些房间有一些满意度,如果满意度 ...

  4. HDU2426:Interesting Housing Problem(还没过,貌似入门题)

    #include <iostream> #include <queue> #include <stdio.h> #include <string.h> ...

  5. codeforces 361 E - Mike and Geometry Problem

    原题: Description Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him ...

  6. CodeForces 689E Mike and Geometry Problem (离散化+组合数)

    Mike and Geometry Problem 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/I Description M ...

  7. Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 离散化 排列组合

    E. Mike and Geometry Problem 题目连接: http://www.codeforces.com/contest/689/problem/E Description Mike ...

  8. Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 离散化+逆元

    E. Mike and Geometry Problem time limit per test 3 seconds memory limit per test 256 megabytes input ...

  9. Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 【逆元求组合数 && 离散化】

    任意门:http://codeforces.com/contest/689/problem/E E. Mike and Geometry Problem time limit per test 3 s ...

随机推荐

  1. spring集成shiro登陆流程(下)

    首先声明入门看的张开涛大神的<跟我学shiro> 示例:https://github.com/zhangkaitao/shiro-example 博客:http://jinnianshil ...

  2. Python学习笔记【第一篇】:认识python和基础知识

    我的笔记里的python代码运行环境都是在pycharm软件中运行,所以不去记录如何配置环境变量呀什么的. python种类 Cpython: Python的官方版本,使用C语言实现,使用最为广泛,C ...

  3. Java数据结构和算法 - 数组

    Q: 数组的创建? A: Java中有两种数据类型,基本类型和对象类型,在许多编程语言中(甚至面向对象语言C++),数组也是基本类型.但在Java中把数组当做对象来看.因此在创建数组时,必须使用new ...

  4. 浅论各种调试接口(SWD、JTAG、Jlink、Ulink、STlink)的区别

    JTAG协议 JTAG(Joint Test Action Group,联合测试行动小组)是一种国际标准测试协议(IEEE 1149.1兼容),主要用于芯片内部测试.现在多数的高级器件都支持JTAG协 ...

  5. python接口自动化(十)--post请求四种传送正文方式(详解)

    简介 post请求我在python接口自动化(八)--发送post请求的接口(详解)已经讲过一部分了,主要是发送一些较长的数据,还有就是数据比较安全等.我们要知道post请求四种传送正文方式首先需要先 ...

  6. Vue.js-05:第五章 - 计算属性与监听器

    一.前言 在 Vue 中,我们可以很方便的将数据使用插值表达式( Mustache 语法)的方式渲染到页面元素中,但是插值表达式的设计初衷是用于简单运算,即我们不应该对差值做过多的操作.当我们需要对差 ...

  7. TabLayoutViewPagerDemo【TabLayout+ViewPager可滑动】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 使用TabLayout搭配ViewPager实现可滑动的顶部选项卡效果. 效果图 代码分析 1.演示常规的设置. 2.通过自定义Vi ...

  8. JavaScript夯实基础系列(五):类

      JavaScript中没有类,是通过使用构造函数和原型模式的组合来实现类似其它面向对象编程语言中"类"的功能.ES6引入的关键字class,形式上向其它面向对象编程语言靠拢,其 ...

  9. 分布式事务解决方案FESCAR

    项目地址:FESCAR 以下是官网的文档.简介2019年,Fescar 是 阿里巴巴 开源的 分布式事务中间件,以 高效 并且对业务 0 侵入 的方式,解决 微服务 场景下面临的分布式事务问题. 1. ...

  10. RDIFramework.NET V3.3 WinForm版角色授权管理新增角色对操作权限项、模块起止生效日期的设置

    在实际应用在我们可能会有这样的需求,某个操作权限项(按钮)或菜单在某个时间范围内可以让指定角色访问.此时通过我们的角色权限扩展设置就可以办到. 在我们框架V3.3 WinForm版全新增加了角色权限扩 ...