bnu 51643 Cactus Exploration
来源:互联网 发布:java 管道 编辑:程序博客网 时间:2024/06/04 18:46
https://www.bnuoj.com/v3/problem_show.php?pid=51643
感谢出题人啊,这题有点像 《嫌疑人X的献身》 里的石神一样,出题喜欢用题面迷惑别人,明明是数学题,非要出的跟图论似得。心累。因为- -鄙人太弱小,导致只推出了部分结论。
解析: 我们讨论特殊情况,当边数m==n-1时,无环,答案为0,当m==n时,只有唯一一个环,答案为n*n,当m
#include <bits/stdc++.h>#define maxs 2020202#define mme(i,j) memset(i,j,sizeof(i))using namespace std;long long n,m;int main(){ int t; scanf("%d",&t); while(t--) { scanf("%lld %lld",&n,&m); if(m==n-1) puts("0"); else if(m==n) printf("%lld\n",n*n); else if( m < n-1 || m > 2*(n-1) ) puts("-1"); else{ long long res=0; long long p=m/(2*(m-n)) ; if( p > 1 ) res=p*m-(m-n)*p*p; p++; res=max(res,p*m-(m-n)*p*p); printf("%lld\n",res); } } return 0;}
0 0
- bnu 51643 Cactus Exploration
- bnu 51643 Cactus Exploration(图论+一元二次方程最值)(北师16校赛)
- cactus
- cactus
- 北京师范大学第十四届ACM决赛 I Cactus Exploration 菊花图,仙人掌树
- BNU
- Cactus入门
- Cactus UVALive
- UVALive3514,Cactus
- 仙人掌[cactus]
- Missing Cactus property [cactus.contextURL]
- pku3618 Exploration
- Exploration poj
- Data Exploration
- Treasure Exploration
- Maze Exploration
- poj2594Treasure Exploration
- UVA784Maze Exploration
- ITK 多张图像转成单个nii.gz或mha文件
- 将已有的项目添加到github
- Tensorflow构建自己的图片数据集TFrecords
- openresty源码剖析——lua代码的加载
- 判断是app打开还是网页打开
- bnu 51643 Cactus Exploration
- 【leetcode】485.解题报告
- 新站SEO方案
- 【DP】洛谷 P1281 书的复制
- 阿里云ECS专有网络服务器禁用了25端口
- shell命令 > 1.txt 这样重定向输出到文件中 不写入了 分析
- Spring Boot 将Freemarker打包到其他jar并在项目中引用的简单方法
- [leetcode]376. Wiggle Subsequence
- 支付宝app集成支付时坑爹的系统超时,请稍后再试 问题。