找规律

D - The Monster and the Squirrel

Ari the monster always wakes up very early with the first ray of the sun and the first thing she does is feeding her squirrel.

Ari draws a regular convex polygon on the floor and numbers it's vertices 1, 2, ..., n in clockwise order. Then starting from the vertex 1 she draws a ray in the direction of each other vertex. The ray stops when it reaches a vertex or intersects with another ray drawn before. Ari repeats this process for vertex 2, 3, ..., n (in this particular order). And then she puts a walnut in each region inside the polygon.

 

Ada the squirrel wants to collect all the walnuts, but she is not allowed to step on the lines drawn by Ari. That means Ada have to perform a small jump if she wants to go from one region to another. Ada can jump from one region P to another region Q if and only if P and Q share a side or a corner.

Assuming that Ada starts from outside of the picture, what is the minimum number of jumps she has to perform in order to collect all the walnuts?

Input

The first and only line of the input contains a single integer n (3 ≤ n ≤ 54321) - the number of vertices of the regular polygon drawn by Ari.

Output

Print the minimum number of jumps Ada should make to collect all the walnuts. Note, that she doesn't need to leave the polygon after.

Example

Input

5

Output

9

Input

3

Output

1

Note

One of the possible solutions for the first sample is shown on the picture above.

#include<stdio.h>

#include<math.h>

int main()

{

int n;

double sum;

scanf("%d",&n);

n=n-2;

    sum=pow(n,2);

    printf("%.0lf",sum);

return 0;

}

 

求平方。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这道题是一个比较典型的规律题目。根据题意,我们需要对给定的数列进行一系列操作,直到最终得到一个数。观察题目中给出的数列,我们可以发现一些规律: 1. 数列中的每个数都是一个四位数,且它们的个位数字都是4。 2. 对于数列中的每个数,它的十位数字都是它的个位数字加上1。 3. 对于数列中的每个数,它的百位数字都是它的十位数字加上1,但是如果它的十位数字为9,则它的百位数字为1。 4. 对于数列中的每个数,它的千位数字都是它的百位数字加上1,但是如果它的百位数字为9且十位数字也为9,则它的千位数字为1。 根据上述规律,我们可以设计一个算法来求解这道题目。具体步骤如下: 1. 将给定的四位数分解为千位、百位、十位和个位数字,分别记为a、b、c和d。 2. 根据第2个规律,计算出新的数列中的数的十位数字,即e=c+1。 3. 根据第3个规律,计算出新的数列中的数的百位数字,即f=b+1,如果c为9,则f=1。 4. 根据第4个规律,计算出新的数列中的数的千位数字,即g=a+1,如果b为9且c为9,则g=1。 5. 将新的千位、百位、十位和个位数字组合成一个新的四位数,并将其作为下一次迭代的输入。 6. 重复步骤2至5,直到得到的数为1474。 下面是一个简单的 Python 代码实现: ```python num = int(input()) # 输入初始的四位数 while num != 1474: a, b, c, d = num // 1000, num // 100 % 10, num // 10 % 10, num % 10 e, f, g = c + 1, b + 1 if c != 9 else 1, a + 1 if b != 9 and c != 9 else 1 num = g * 1000 + f * 100 + e * 10 + 4 print("成功得到 1474!") ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值