Parallel and Perpendicular

题目链接

  • 题意:

    输入n,求正n边形中的对角线1和对角线2的个数(对角线1:至少与其它一个对角线平行;对角线2:至少与其它一个对角线垂直)。对角线不能是多边形的边

    (4 ≤ n ≤ 10e5)

  • 分析:

    思路题。无论是几边形,两个平行边中间所夹的两側的边数必须是同样的。也就是说两个端点朝着一个方向移动若干个短点后能够得到还有一条平行边。

    也就是说,多边形的每一条边都存在平行便(6边形的时候有一点特殊情况单独处理)

    垂直比較麻烦:对于n是偶数的情况,能够得到,每一个点的n-3条边都是对角线2(n为偶数的时候,随意一条对角线一定将原图形分成左右两个对称的图形)。n为奇数时候,没有对角线2(仅仅能是推測)

int a[2][110];
int main()
{
    int n;
    a[0][4] = 0;
    a[0][5] = 0;
    a[0][6] = 6;
    a[1][4] = 2;
    a[1][5] = 0;
    a[1][6] = 9;
    while (~RI(n))
    {
        if (n <= 6)
        {
            printf("%d %d\n", a[0][n], a[1][n]);
        }
        else
        {
            cout << 1LL * (n - 3) * n / 2 << ‘ ‘;
            if (n & 1) cout << 0 << endl;
            else cout << 1LL * (n - 3) * n / 2 << endl;
        }
    }
    return 0;
}
时间: 2024-08-28 22:56:58

Parallel and Perpendicular的相关文章

URAL 1981. Parallel and Perpendicular(数学 )

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1981 You are given a regular n-gon. Your task is to calculate two values: the number of its diagonals that are parallel to at least one of its other diagonals, and the number of its diagonals that are

Axis&#173; Aligned ?Rectangles

Describe ?an? algorithm ?that ?takes ?an ?unsorted ?array ?of ?axis‐aligned ?rectangles ?and? returns ?any ?pair ?of ?rectangles ?that? overlaps,? if ?there? is ?such? a ?pair.? ?Axis‐aligned? means? that? all ?the? rectangle? sides? are ?either ?par

(转载)Cross product

原文地址:https://en.wikipedia.org/wiki/Cross_product Cross product From Wikipedia, the free encyclopedia This article is about the cross product of two vectors in three-dimensional Euclidean space. For other uses, see Cross product (disambiguation). In m

005.草图功能

第4章 草图功能 本章主要内容: ? 草图工具对话框 ? 草图功能选项 ? 草图约束 ? 草图操作 ? 草图管理 ? 编辑草图 ? 本章实例 4.1 草图工具对话框 草图(Sketch)是与实体模型相关联的二维图形,一般作为三维实体模型的基础.该功能可以在三维空间中的任何一个平面内建立草图平面,并在该平面内绘制草图.草图中提出了"约束"的概念,可以通过几何约束与尺寸约束控制草图中的图形,可以实现与特征建模模块同样的尺寸驱动,并可以方便的实现参数化建模.应用草图工具,用户可以绘制近似的曲

字体jquery ---

You don’t need icons! Here are 100+ unicode symbols that you can use Danny Markov December 3rd, 2014 Ever needed to add an icon to your design, but you didn’t want to include images or an entire icon font like Font Awesome into your page? We’ve got g

大量数据快速插入方法探究[nologging+parallel+append]

大量数据快速插入方法探究 快速插入千万级别的数据,无非就是nologging+parallel+append. 1     环境搭建 构建一个千万级别的源表,向一个空表insert操作. 参考指标:insert动作完成的实际时间. SQL> drop table test_emp cascadeconstraints purge; Table dropped. SQL> create table test_emp as select *from emp; Table created. SQL&

SMON: Parallel transaction recovery tried 引发的问题--转载

SMON: Parallel transaction recovery tried 这个一般是在具有在跑大数据量的 transaction的时候kill掉了进程而导致 smon 去清理 回滚段时导致的. 这个在业务高峰期的时候,如果发现这个,有可能导致 SMON 占用了 100% cpu 而导致 系统 hang 在那边.即使你shutdown immediate ,oracle 也会等待 smon 清理完毕才能关机,而这个等待过程也许是漫长的.如果你 shutdown abort,那么oracl

【狼窝乀野狼】Parallel浅尝辄止

前段时间看到园子里面有同学在用Parallel进行批量插入数据库.后面也有很多同学针对这一事件给出了自己的看法和见解.我在这里不评论内容的好坏,至少能将自己东西总结分享这个是要靠勇气和毅力. 闲话少说,我在最近看崔鹏飞的github的时候,发现他对这块也做了一定的总结,那么我就他这块进行板书与展示.案例是怎么回事呢?话说我有一个公司,里面需要统计一下总收入,另外有一个公司被我收购了,我一起计算总收入.当一天我收购了N个公司,计算总收入的时候,我们采用并行计算. 1 internal class

Parallel并行化编程

在很多场景中我们需要通过并行化的方式来提高程序运行的速度,比较典型的需求就是并行下载.前期遇到一个需求是要批量下载瓦片,每次大概下载上百万个瓦片,要想提高瓦片的下载速度,只能通过并行化的方式,下面把我解决此问题的思路和代码总结如下: 第一步确定线程个数(ThreadCount),这个要根据网络情况和硬件配置进行确定,可以做成一个配置项由用户自行确定. 第二步将任务分成ThreadCount个,此步需要注意处理任务数较少(小于线程个数)以及任务数除不尽ThreadCount的情况.处理方式为任务数