Codeforces 916C - Jamie and Interesting Graph
916C - Jamie and Interesting Graph
思路:构造。
对于1到n最短路且素数,那么1到n之间连2
对于最小生成树,找一个稍微大点的素数(比1e5大)构造一个和为这个素数的最小生成树
剩下的边都连1e9
代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a)) /*const int N=1e5+5;
const int M=1e7+7;
vector<int>vc;
bool not_prime[M];
void prime(){
for(int i=2;i<M;i++){
if(!not_prime[i])vc.pb(i);
for(int j=0;i*vc[j]<M;j++){
not_prime[i*vc[j]]=true;
if(i%vc[j]==0)break;
}
}
cout<<vc[vc.size()-1]<<endl;//9999991
}*/
int main(){
ios::sync_with_stdio(false);
cin.tie();
//prime();
int n,m,t=;
cin>>n>>m;
if(n==)cout<<<<' '<<<<endl;
else cout<<<<' '<<t<<endl;
cout<<<<' '<<n<<' '<<<<endl;
t-=;
for(int i=;i<n;i++){
if(i!=n-)cout<<<<' '<<i<<' '<<<<endl,t-=;
else cout<<<<' '<<i<<' '<<t<<endl;
}
m-=n-;
for(int i=;i<=n;i++){
if(m==)break;
for(int j=i+;j<=n;j++){
if(m==)break;
cout<<i<<' '<<j<<' '<<<<endl;
m--;
if(m==)break;
}
if(m==)break;
}
return ;
}
Codeforces 916C - Jamie and Interesting Graph的更多相关文章
- CodeForces 916C Jamie and Interesting Graph (构造)
题意:给定两个数,表示一个图的点数和边数,让你构造出一个图满足 1- n 的最短路是素数,并且最小生成树也是素数. 析:首先 1 - n 的最短路,非常好解决,直接 1 连 n 就好了,但是素数尽量 ...
- Jamie and Interesting Graph CodeForces - 916C
http://codeforces.com/problemset/problem/916/C 好尬的题啊... #include<cstdio> #include<algorithm ...
- 【Codeforces Round #457 (Div. 2) C】Jamie and Interesting Graph
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 找比n-1大的最小的素数x 1-2,2-3..(n-2)-(n-1)长度都为1 然后(n-1)-n长度为(x-(n-2)) 然后其他 ...
- CF916C Jamie and Interesting Graph
思路:构造 实现: #include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n ...
- Codeforces 1109D. Sasha and Interesting Fact from Graph Theory
Codeforces 1109D. Sasha and Interesting Fact from Graph Theory 解题思路: 这题我根本不会做,是周指导带飞我. 首先对于当前已经有 \(m ...
- Codeforces Beta Round #9 (Div. 2 Only) E. Interesting Graph and Apples 构造题
E. Interesting Graph and Apples 题目连接: http://www.codeforces.com/contest/9/problem/E Description Hexa ...
- Codeforces 703D Mishka and Interesting sum 离线+树状数组
链接 Codeforces 703D Mishka and Interesting sum 题意 求区间内数字出现次数为偶数的数的异或和 思路 区间内直接异或的话得到的是出现次数为奇数的异或和,要得到 ...
- Codeforces 1109D Sasha and Interesting Fact from Graph Theory (看题解) 组合数学
Sasha and Interesting Fact from Graph Theory n 个 点形成 m 个有标号森林的方案数为 F(n, m) = m * n ^ {n - 1 - m} 然后就 ...
- Codeforces 1109D. Sasha and Interesting Fact from Graph Theory 排列组合,Prufer编码
原文链接https://www.cnblogs.com/zhouzhendong/p/CF1109D.html 题意 所有边权都是 [1,m] 中的整数的所有 n 个点的树中,点 a 到点 b 的距离 ...
随机推荐
- OpenCV Mat数据类型及位数总结(转载)
OpenCV Mat数据类型及位数总结(转载) 前言 opencv中很多数据结构为了达到內存使用的最优化,通常都会用它最小上限的空间来分配变量,有的数据结构也会因为图像文件格式的关系而给予适当的变量, ...
- POJ 3461 Oulipo(KMP,模式串在主串中出现次数 可重叠)
题意:给你两个字符串p和s,求出p在s中出现的次数. 显然,我们要先把模式串放到前面,之后主串放后面,中间隔开,这样就可以根据前缀数组的性质来求了. 我先想直接把p接到s前面,之后求Next数组对st ...
- C# NPOI 操作excel
转载的文章,方便自己查看. 一.下载NPOI:http://down.gougou.com/down?cid=DAEA322D9D7F934B898077FB01C3A8CB02A746E6 二.项目 ...
- kendo column chart
目录 1.用js操作chart, 2.tooltip template鼠标悬浮显示内容, 3.双坐标轴,axisCrossingValues: [0, 30],3指的是跨越横坐标轴标签项数,显示在右 ...
- zw版【转发·台湾nvp系列Delphi例程】HALCON ZoomImageFactor2
zw版[转发·台湾nvp系列Delphi例程]HALCON ZoomImageFactor2 procedure TForm1.Button1Click(Sender: TObject);var op ...
- Hive四种数据导入方式介绍
问题导读 1.从本地文件系统中通过什么命令可导入数据到Hive表? 2.什么是动态分区插入? 3.该如何实现动态分区插入? 扩展: 这里可以和Hive中的三种不同的数据导出方式介绍进行对比? Hive ...
- 2018-2019-2 20165209 《网络对抗技术》Exp5:MSF基础应用
2018-2019-2 20165209 <网络对抗技术>Exp5:MSF基础应用 目录 一.基础问题回答和实验内容 二.攻击实例 主动攻击的实践 ms08_067 payload/gen ...
- Linux基础命令---comm
comm 逐行比较两个已经排序过的文件.结果以3列显示:第1列显示只在file1出现的内容,第2列显示只在file2出现的内容,第3列显示同时出现的内容. 此命令的适用范围:RedHat.RHEL.U ...
- apache 中 ServerAlias让多个域名绑定到同一空间
在apache的虚拟主机中,如果书写了.ServerAlias www.a2.com www.a3.com这样的语句,就可以给虚拟主机增加多个域名,而且这些域名都访问同一个站点. #Listen 81 ...
- HTML5 -canvas拖拽、移动 绘制图片可操作移动,拖动
关于canvas 的基础知识就不多说了,可以进这个网址学习 http://www.w3school.com.cn/html5/html_5_canvas.asp 对于canvas 和 SVG 其实一开 ...