当前位置:网站首页>P2181 对角线和P1030 [NOIP2001 普及组] 求先序排列
P2181 对角线和P1030 [NOIP2001 普及组] 求先序排列
2022-07-04 22:31:00 【&volume】
目录
----------------------
题目描述
对于一个 nn 个顶点的凸多边形,它的任何三条对角线都不会交于一点。请求出图形中对角线交点的个数。
例如,66 边形:

输入格式
输入只有一行一个整数 nn,代表边数。
输出格式
输出一行一个整数代表答案。
输入输出样例
输入 #1复制
3
输出 #1复制
0
输入 #2复制
6
输出 #2复制
15
说明/提示
数据规模与约定
- 对于 50 \%50% 的数据,保证 3 \leq n \leq 1003≤n≤100。
- 对于 100 \%100% 的数据,保证 3 \leq n \leq 10^53≤n≤105
# include <bits/stdc++.h>//# include <math.h>
int main()
{
unsigned long long n=0;
using namespace std;
unsigned long long m=0;
cin>>n;
m=n*(n-1)/2*(n-2)/3*(n-3)/4;
cout<<m;
return 0;
}--------------------------------------------------------------------------------------------------------------------------------
题目描述
给出一棵二叉树的中序与后序排列。求出它的先序排列。(约定树结点用不同的大写字母表示,且二叉树的节点个数 \le 8≤8)。
输入格式
共两行,均为大写字母组成的字符串,表示一棵二叉树的中序与后序排列。
输出格式
共一行一个字符串,表示一棵二叉树的先序。
输入输出样例
输入 #1复制
BADC BDCA
输出 #1复制
ABCD
说明/提示
【题目来源】
NOIP 2001 普及组第三题
# include <bits/stdc++.h>
using namespace std;
void stdlb (string a,string b)
{
if(a.size()>0)
{
char c=b[b.length()-1];
cout<<c;
int k=a.find(c);
stdlb(a.substr(0,k),b.substr(0,k));
stdlb(a.substr(k+1),b.substr(k,b.length()-k-1));
}}
int main()
{
string a;
cin>>a;
string b;
cin>>b;
stdlb(a,b);
return 0;
}边栏推荐
猜你喜欢

The new version judges the code of PC and mobile terminal, the mobile terminal jumps to the mobile terminal, and the PC jumps to the latest valid code of PC terminal

Attack and defense world misc advanced zone 2017_ Dating_ in_ Singapore

It is said that software testing is very simple, but why are there so many dissuasions?

sobel过滤器

Google Earth engine (GEE) - globfire daily fire data set based on mcd64a1

Redis入门完整教程:慢查询分析

Attack and defense world misc advanced area can_ has_ stdio?

攻防世界 misc 高手进阶区 a_good_idea

The overview and definition of clusters can be seen at a glance

A complete tutorial for getting started with redis: Pipeline
随机推荐
剑指 Offer 65. 不用加减乘除做加法
浅聊一下中间件
Google Earth Engine(GEE)——基于 MCD64A1 的 GlobFire 日常火灾数据集
In Linux, I call odspcmd to query the database information. How to output silently is to only output values. Don't do this
A complete tutorial for getting started with redis: redis shell
[the 2023 autumn recruitment of MIHA tour] open [the only exclusive internal push code of school recruitment eytuc]
MySQL Architecture - user rights and management
NFT Insider #64:电商巨头eBay提交NFT相关商标申请,毕马威将在Web3和元宇宙中投入3000万美元
The new version judges the code of PC and mobile terminal, the mobile terminal jumps to the mobile terminal, and the PC jumps to the latest valid code of PC terminal
关于栈区、堆区、全局区、文字常量区、程序代码区
繁华落尽、物是人非:个人站长该何去何从
9 - 类
Redis入门完整教程:慢查询分析
9 - class
Unity修仙手游 | lua动态滑动功能(3种源码具体实现)
Redis入门完整教程:有序集合详解
Common methods in string class
攻防世界 MISC 进阶区 hong
The Sandbox 和数字好莱坞达成合作,通过人力资源开发加速创作者经济的发展
醒悟的日子,我是怎么一步一步走向软件测试的道路