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 的距离 ...
随机推荐
- 将Mongo装为Windows的服务
PHP的mongo扩展: 首先 下载一个PHP的mongo扩展, 地址:http://download.csdn.net/detail/qq_36387589/9819259 然后修改php.ini. ...
- c#null值加法运算
加号都是一个含义啊,操作数不同,加号重载的方法就不一样,当加号的左边或右边含有字符串的时候,总是返回一个不为空的字符串.当加号左右两边都是数值的时候,就会对其进行数学运算,null+任何数都为null ...
- CFA
拜耳色彩滤波阵列(Bayer Color Filter Array, CFA)是非常有名的彩色图片的数字采集格式.由1/2的G,1/4得R,1/4的B组成. 当Image Sensor向外逐行输出数据 ...
- SV中的数据类型
Verilog-1995中规定的数据类型有:变量(reg), 线网(wire), 32位有符号数(integer), 64位无符号数(time), 浮点数(real). SV扩展了reg类型为logi ...
- cygwin本地.bashrc配置
echo -e "====================================================================================== ...
- Python: os.listdir()
os.listdir(): 返回一个列表,此列表包含参数路径下的的文件名或文件夹名.这个列表以字母为顺序. eg: >>>import os >>>dirs=os. ...
- 基于GIT的管理
常用命令 git init : 初始化仓库git add 文件名 :把文件添加到暂存区git commit -m "操作记录" : 提交到仓库,设置相关操作的记录 git stat ...
- 我是怎么样和Linux结缘并通过红帽RHCE认证的
我高考完当时就是选择的计算机科学与技术专业,上大学以后联想到的和计算机相关的就只有写代码,开发,网站,网页设计,就没有其他的了,当时学习写代码也都是在Windows上,什么C#.C++之类的?大约在大 ...
- Python3 爬取微信好友基本信息,并进行数据清洗
Python3 爬取微信好友基本信息,并进行数据清洗 1,登录获取好友基础信息: 好友的获取方法为get_friends,将会返回完整的好友列表. 其中每个好友为一个字典 列表的第一项为本人的账号信息 ...
- rabbitmq架构简介(包括集群)
总的来说,rabbitmq使用erlang语言编写,其架构类似于servlet容器运行servlet应用,底层是erlang VM.然后是erlang节点,上面是应用.如下所示: 每个MQ中运行的应用 ...