当前位置:网站首页>2022信息与未来预备刷题1《New Online Judge 1112: 平面分割》
2022信息与未来预备刷题1《New Online Judge 1112: 平面分割》
2022-04-21 10:00:00 【joe_zxq的编程世界】
P1112 - 平面分割 - New Online Judge
http://oj.ecustacm.cn/problem.php?id=1112
内存限制:256 MB时间限制:1 S标准输入输出
题目类型:传统评测方式:文本比较上传者:外部导入
提交:157通过:121
题目描述
同一平面内有n(n≤500)条直线,已知其中p(p≥2)条直线相交于同一点,则这n条直线最多能将平面分割成多少个不同的区域?
输入格式
两个整数n(n≤500)和p(2≤p≤n)
输出格式
一个正整数,代表最多分割成的区域数目。
输入样例 复制
12 5
输出样例 复制
73
分类标签
思路:
公式
int f[N]; f[p]=2*p; for(int i=p+1;i<=n;i++)f[i]=f[i-1]+i;
AC代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vll2 vector<ll,vector<ll> >
#define vi2 vector<int,vector<int> >
#define pii pair<int,int>
#define pll pair<ll,ll>
int main(){
int p,n;
cin>>n>>p;
vi v(n+5);
for(int i=0;i<v.size();i++) v[i]=0;
v[p]=2*p;
for(int i=p+1;i<n+1;i++) v[i]=v[i-1]+i;
cout<<v[n];
return 0;
}
//ACplease!!!
/* printf(" \n");
printf(" \n");
printf(" * * * * * * * * * * * * \n");
printf(" * * * * * * * * \n");
printf(" * * * * * * * * \n");
printf(" * * * * * \n");
printf(" * * * * * \n");
printf(" * * * * * \n");
printf(" * * * * * \n");
printf(" * * * * * \n");
printf(" * * * * * \n");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * \n");
*/
版权声明
本文为[joe_zxq的编程世界]所创,转载请带上原文链接,感谢
https://blog.csdn.net/joe_zxq21/article/details/124307896
边栏推荐
- My creation anniversary
- [hand in hand to prepare you for the video game] detailed explanation of April tag tag tracking (3D positioning)
- [pytorch] monai Vit 网络 图文分析
- 【手拉手 带你准备电赛】近期小总结
- 【无标题】
- CentOS下Docker中安裝MySQL
- Fudan University - University of Washington EMBA Alumni: Turning "her power" into "our power"
- [Yugong series] April 2022 wechat applet - Project (bus query) - 01 surrounding stations
- ant a-table 树表格级联选择
- 控制另一个程序的启动、隐藏、显示、关闭
猜你喜欢

ant a-table 表格数据同步

Using pycharm to load the QRC resource file in pyside2

Daily question (2022-04-19) - the shortest distance of characters

Daily question (2022-04-20) - the longest absolute path of the file
![[excel function] count function | countif function | countifs function](/img/fa/440ea44a9fa5a74fe4b8fc172dd493.png)
[excel function] count function | countif function | countifs function

Canoe: what is the vector tool platform

A tool that is easier to use and more powerful than Navicat!
Transaction isolation level and mvcc

网站被挂博彩暗链

【并发编程045】什么是伪共享内存顺序冲突?如何避免?
随机推荐
ROS与MATLAB网络连接
Ansible_ 03_ Advanced Playbook
Ant a-table tree table cascade selection
[hand in hand to prepare you for the video game] monochrome block recognition (based on openmv)
大/小根堆
Ansible_03_高级playbook
[pytorch] monai Vit 网络 图文分析
On the three paradigms of database design
C#字符串提供的各种方法
[Yugong series] wechat applet - Online aggregation of maps in April 2022
[note] package XML file syntax record
ant a-table 树表格级联选择
Uniapp style penetration
网站被挂博彩暗链
【DL-图像分类】
Yuanshu training dance room, cyberpunk cool style, waiting for you to dance
2022年危险化学品生产单位安全生产管理人员特种作业证考试题库模拟考试平台操作
Sixtool, which is launched in the whole network, is a multi-functional and multi-in-one generation hanging assistant. It supports BiliBili, movement steps and other functions. The operating version ca
[pycharm plugins] download online to install the translation plug-in
Fashion cloud learning -js implementation disables right click and F12