当前位置:网站首页>P2181 diagonal
P2181 diagonal
2022-07-29 04:54:00 【Chen Yuchen】
For one nn A convex polygon with vertices , None of its three diagonals meet at one point . Request the number of diagonal intersections in the drawing .
Input format
Enter only one line and one integer nn, Represents the number of edges .
Output format
Output a line with an integer representing the answer .
I/o sample
Input #1 Copy
3
Output #1 Copy
0
Input #2 Copy
6
Output #2 Copy
15
import java.math.BigInteger;
import java.util.*;
/* Mathematical derivation , When the vertex is less than 4 There can be no intersection , When the vertex equals four, there is and only one , that When the vertex is larger than four, we can combine the vertices , Application Cn To see how many possibilities there are ! */
public class Main{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
// The range of basic data types cannot accept all data , So here we need to use two classes of infinity BigInteger( integer ) and BigDecimal( floating-point )
BigInteger bd1 = new BigInteger(String.valueOf(n));
BigInteger bd2 = new BigInteger(String.valueOf(n-1));
BigInteger bd3 = new BigInteger(String.valueOf(n-2));
BigInteger bd4 = new BigInteger(String.valueOf(n-3));
BigInteger bd5 = new BigInteger("24");
bd1 = bd1.multiply(bd2);
bd1 = bd1.multiply(bd3);
bd1 = bd1.multiply(bd4);
if(n<=3)
System.out.println(0);
else {
bd1 = bd1.divide(bd5);
System.out.println(bd1);
}
}
}
边栏推荐
猜你喜欢

Detailed comparison of break and continue functions

Classes and objects (I)

The difference between the two ways of thread implementation - simple summary

如何避免示波器电流探头损坏

Auto.js脚本开发环境搭建

Stack and queue and priority queue (large heap and small heap) simulation implementation and explanation of imitation function

Five correlation analysis, one of the most important skills of data analysts

spinning up安装完使用教程测试是否成功,出现Library“GLU“ not found和‘from pyglet.gl import *错误解决办法

Climbing the pit of traffic flow prediction (III): using pytorch to realize LSTM to predict traffic flow

Classes and objects (III)
随机推荐
Deep analysis of data storage in memory (Advanced C language)
如何安装office2010安装包?office2010安装包安装到电脑上的方法
新产品上市最全推广方案
Flink+iceberg environment construction and production problem handling
命令行交互工具(最新版) inquirer 实用教程
EF core: one to one, many to many configuration
带你一文理解JS数组
Spark的算子操作列表
iOS面试准备 - ios篇
The most complete NLP Chinese and English stop words list in the whole station (including punctuation marks, which can be copied directly)
PHP determines whether the user has logged in. If logged in, the home page will be displayed. If not, enter the login page or registration page
电脑无法打开excel表格怎么办?excel打不开的解决方法
Implementation of flutter gesture monitoring and Sketchpad
Word如何查看文档修改痕迹?Word查看文档修改痕迹的方法
Basic grammar of C language
Exception - ...MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is ...
带你搞懂 Kubernetes 集群中几种常见的流量暴露方案
RecyclerView通过DPAD按键上下切换焦点 切换到界面外的控件时焦点会左右乱跳
Learn matlab to draw geographical map, line scatter bubble density map
Conv1d of torch