【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))
然后其他边长度都设为x+1就好了。
这样就能满足题意了。
【代码】
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,ma;
bool is(int x){
if (x<2) return false;
int len = sqrt(x);
for (int i = 2;i <= len;i++){
if (x%i==0)
return false;
}
return true;
}
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
cin >> n >> m;
for (int i = n-1;;i++)
if (is(i)){
ma = i;
break;
}
cout <<ma<<' '<<ma<<endl;
for (int i = 1;i <= n-2;i++){
cout <<i<<' '<<i+1<<" 1"<<endl;
}
cout <<n-1<<" "<<n<<" "<<ma-(n-2)<<endl;
int now = n-1;
for (int i = 1;i <= n &&now<m;i++)
for (int j = i+1;j <= n && now <m;j++){
if (j != (i+1)){
cout <<i<<" "<<j<<" "<<ma+1<<endl;
now++;
}
}
return 0;
}
【Codeforces Round #457 (Div. 2) C】Jamie and Interesting Graph的更多相关文章
- 【Codeforces Round #457 (Div. 2) B】Jamie and Binary Sequence
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 把n分解成二进制的形式. n=2^a0+2^a1+...+2^a[q-1] 则固定就是长度为q的序列. 要想扩展为长为k的序列. 可 ...
- 【Codeforces Round #457 (Div. 2) A】 Jamie and Alarm Snooze
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 暴力往前走x分钟就好. 直到出现7为止. [代码] #include <bits/stdc++.h> using nam ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
- 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
- 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
- 【Codeforces Round #423 (Div. 2) C】String Reconstruction
[Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...
- 【Codeforces Round #423 (Div. 2) B】Black Square
[Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...
- 【Codeforces Round #423 (Div. 2) A】Restaurant Tables
[Link]:http://codeforces.com/contest/828/problem/A [Description] 有n个组按照时间顺序来餐馆; 每个组由一个人或两个人组成; 每当有一个 ...
随机推荐
- 10-while和dowhile语句
- 【习题 8-17 UVA - 11536】Smallest Sub-Array
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 尺取法. 考虑一个1..i的窗口. 里面在到达了i位置的时候恰好有1..k这些数字了. 为了更接近答案. 显然可以试着让左端点变成2 ...
- Hadoop学习总结(1)——大数据以及Hadoop相关概念介绍
一.大数据的基本概念 1.1.什么是大数据 大数据指的就是要处理的数据是TB级别以上的数据.大数据是以TB级别起步的.在计算机当中,存放到硬盘上面的文件都会占用一定的存储空间,例如: 文件占用的存储空 ...
- POJ 1723 SOLDIERS
SOLDIERS Time Limit: 1000ms Memory Limit: 10000KB This problem will be judged on PKU. Original ID: 1 ...
- AP设备漫游阈值设置
在多个AP部署的场景下,默认情况下,手持移动设备(如PDA.手机)信号弱到断掉时才切换AP,无线信号很弱的情况下网络是非常的不稳定的,因此我们需要配置AP设备的漫游阈值(RSSI阈值),以便连接的无线 ...
- 千千万万的IT开发project师路在何方
已经找不到该文章的最初出处了,有找到的人请告诉我.谢谢~~ 千千万万的IT开发project师路在何方 2007-06-25 21:41 恭喜,你选择开发project师作为自已的职业! 悲哀.你选择 ...
- POJ 1887 Testingthe CATCHER (LIS:最长下降子序列)
POJ 1887Testingthe CATCHER (LIS:最长下降子序列) http://poj.org/problem?id=3903 题意: 给你一个长度为n (n<=200000) ...
- DataTable转成Json
/// <summary> /// DataTable转成Json /// </summary> /// <param name=&quo ...
- 19. idea 创建多模块依赖Maven项目
转自:https://www.cnblogs.com/runnerjack/p/9269526.html 本来网上的教程还算多,但是本着自己有的才是自己的原则,还是自己写一份的好,虽然可能自己也不会真 ...
- 一张图了解javaJwt
1.什么是javaJwt? JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims ...