cf#328-B. The Monster and the Squirrel-水题+数学规律

http://codeforces.com/contest/592/problem/B

给你一个正n边型

让你在每个顶点画n-3条线 与别的顶点连起来 

(如果从某个顶点发出线段的过程遇到连过的线。则发出的线就被截断,)

(如果a-b已经有线了,轮到b时,就不用对a射出一条线)  

求出最后把整个正n边形分成几块


画了个6边形,

发现 第一个顶点可以分成n-2块,第二个顶点可以分多 n-3块

然后剩下的 除了最后一个顶点 都是分成n-4块 

最后一个顶点是 n-3块。。


#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <vector>
using namespace std; 
__int64 min(__int64 a,__int64 b)
{
    return a<b?a:b;
}
int main()
{
    
    __int64 n;
scanf("%I64d",&n);
    __int64 i;
    __int64 tt=n-2;
    __int64 ans=n-2+n-3;
    for (i=3;i<n;i++)
    {
        ans+=n-4;
    }
    if (n>=4)
        ans+=n-3;
    
    printf("%I64d\n",ans);
    
    
    return 0;
    
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值