3195 圆环套圆环


Submit solution

Points: 10
Time limit: 2.0s
Memory limit: 250M

Problem types
Allowed languages
C, C++, Java, Python

背景

IMO2006 CTSC TEST3

描述

一个有趣的圆环套圆环函数被定义如下:
G(n)=n-G(G(n-1)) (n是正整数)
G(0)=0
请你计算出圆环函数的值。

输入格式

一个非负整数n,n<=2^31-1。

输出格式

一个正整数,即G(n)。

样例输入

3

样例输出

2

限制

各个测试点1s

提示

典型数学竞赛题......


Comments

There are no comments at the moment.