首页 > 其他分享 >codeforces round The Monster and the Squirrel 529B (数学规律)

codeforces round The Monster and the Squirrel 529B (数学规律)

时间:2023-04-20 17:38:12浏览次数:45  
标签:Monster Input codeforces she Ada Ari ray 529B first


The Monster and the Squirrel


Time Limit: 1000MS

 

Memory Limit: 262144KB

 

64bit IO Format: %I64d & %I64u


Submit Status


Description



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




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


Sample Input



Input



5



Output



9



Input



3



Output



1


Hint



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

 

//题意可转化为给你一个凸多边形,每个点有标号为1,2,3,........n。从1向不与它相邻的点连线,然后依次是2,3,....n,但后边的不能穿过前面的线。问这么多的线把这个凸多边形分为几部分。

枚举前几个发现规律

#include<stdio.h>
#include<string.h>
int main()
{
	__int64 n,m;
	while(scanf("%I64d",&n)!=EOF)
	{
		printf("%I64d\n",(n-2)*(n-2));
	}
	return 0;
}

 

标签:Monster,Input,codeforces,she,Ada,Ari,ray,529B,first
From: https://blog.51cto.com/u_16079508/6210019

相关文章

  • Codeforces Round 850 (Div. 2, based on VK Cup 2022 - Final Round) E. Monsters (h
    传送门详细题解传送门  抄的ygg代码,向在这里说一下刚开始没看懂的部分。  求答案的时候是把所有的当前为止的所有数值加起来减去一个从1开始并且公差为1的等差数列的前size项和。其中size是当前最多能用到哪个位置,满足前size项能构成1,2,3,....,sz这样的形式。  假设我们......
  • CodeForces - 610B Vika and Squares (模拟)
    CodeForces-610BVikaandSquaresTimeLimit: 2000MS MemoryLimit: 262144KB 64bitIOFormat: %I64d&%I64uSubmit StatusDescriptionVikahas n jarswithpaintsofdistinctcolors.Allthejarsarenumberedfrom 1 to n andthe......
  • CodeForces - 659C Tanya and Toys (map&模拟)
    CodeForces-659CTanyaandToysTimeLimit: 1000MS MemoryLimit: 262144KB 64bitIOFormat: %I64d&%I64uSubmit StatusDescriptionInBerlandrecentlyanewcollectionoftoyswentonsale.Thiscollectionconsistsof 109 typesof......
  • CodeForces - 367B Sereja ans Anagrams (map)
    CodeForces-367BSerejaansAnagramsTimeLimit: 1000MS MemoryLimit: 262144KB 64bitIOFormat: %I64d&%I64uSubmit StatusDescriptionSerejahastwosequences a and b andnumber p.Sequence a consistsof n integers a1, a......
  • CodeForces - 368C Sereja and Algorithm (找规律&模拟)
    CodeForces-368CSerejaandAlgorithmTimeLimit: 1000MS MemoryLimit: 262144KB 64bitIOFormat: %I64d&%I64uSubmit StatusDescriptionSerejalovesallsortsofalgorithms.Hehasrecentlycomeupwithanewalgorithm,whichreceiv......
  • CodeForces - 616E Sum of Remainders (数论)大数取余求和 好题
    CodeForces-616ESumofRemaindersTimeLimit: 2000MS MemoryLimit: 262144KB 64bitIOFormat: %I64d&%I64uSubmit StatusDescriptionCalculatethevalueofthesum: nmod1 + nmod2 + nmod3 +...+ nmodm.Astheresultcanbeve......
  • Educational Codeforces Round 113 (Rated for Div. 2)
    题目链接B核心思路这个题目我觉得很好。首先分析下吧,如果有人需要执行操作二那么我们肯定就是给他们都打上平局是最优的。那么如果有人需要执行操作一呢,那么我们就可以把这些需要执行操作1的都搞一起。然后是他们成一个环。这样肯定就保证了每个人都会赢上一次。C核心思路......
  • Codeforces Round 866 (Div. 2)
    A.Yura'sNewName一个简单的dp,状态是\(f[i][0/1]\)表示前\(i\)位变成合法的且最后一位是^或_的最小代价。如果是_只能从^转移过来,如果是^则都可以转移过来#include<bits/stdc++.h>usingnamespacestd;voidsolve(){ strings; cin>>s; intn=s.size(); if(n=......
  • Codeforces Dp
    ZeroRemainderSum  采用辅助数组$ndp[m+1][\frac{m}{2}][k]$来求出每一行中在当前第$i$列,取了$j$个物品,总和模$k$的余数是$t$的最大和是多少。用$dp[n+1][k]$来转移每一行的状态。#include<bits/stdc++.h>usingnamespacestd;const......
  • Codeforces 1810G - The Maximum Prefix(DP)
    挺小清新的一道计数题。首先先分析下这个“最大前缀和”,按照最朴素的思路就是扫一遍每个前缀,然后记录一下当前的\(sum\)与前面的\(mx\),但是如果你一直陷在这个思路上你就似了,因为按照这个思路做,你DP状态里需要记录\(sum\)和\(mx\)两个维度,算上下标一维总共是\(n^3\),并......