【Codeforces 1009D】Relatively Prime Graph
【链接】 我是链接,点我呀:)
【题意】
题意
【题解】
1000以内就有非常多组互质的数了(超过1e5)
所以,直接暴力就行...很快就找完了
(另外一开始头n-1条边找1和2,3...n就好
【代码】
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
vector<pair<int,int> > v;
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> n >> m;
if (m<n-1){
cout<<"Impossible"<<endl;
}else {
for (int i = 1;i <= n && m>0;i++)
for (int j = i+1;j <= n && m > 0;j++){
if (__gcd(i,j)==1){
v.push_back(make_pair(i,j));
m--;
}
}
if (m>0){
cout<<"Impossible"<<endl;
}else{
cout<<"Possible"<<endl;
for (pair<int,int> temp:v){
cout<<temp.first<<" "<<temp.second<<endl;
}
}
}
return 0;
}
【Codeforces 1009D】Relatively Prime Graph的更多相关文章
- 【codeforces 716D】Complete The Graph
[题目链接]:http://codeforces.com/problemset/problem/716/D [题意] 给你一张图; 这张图上有一些边的权值未知; 让你确定这些权值(改成一个正整数) 使 ...
- Codeforces 1009D:Relatively Prime Graph
D. Relatively Prime Graph time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- 【Codeforces 340D】Bubble Sort Graph
[链接] 我是链接,点我呀:) [题意] 让你根据冒泡排序的规则 建立一张图 问你这张图的最大独立子集的大小 [题解] 考虑a[i]会和哪些点连边? 必然是在a[i]左边且比它大的数字以及在a[i]右 ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【Azure Developer】使用Microsoft Graph API 批量创建用户,先后遇见的三个错误及解决办法
问题描述 在先前的一篇博文中,介绍了如何使用Microsoft Graph API来创建Azure AD用户(博文参考:[Azure Developer]使用Microsoft Graph API 如 ...
- 【codeforces 755E】PolandBall and White-Red graph
[题目链接]:http://codeforces.com/contest/755/problem/E [题意] 给你n个节点; 让你在这些点之间接若干条边;构成原图(要求n个节点都联通) 然后分别求出 ...
- 【34.57%】【codeforces 557D】Vitaly and Cycle
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【27.91%】【codeforces 734E】Anton and Tree
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【30.36%】【codeforces 740D】Alyona and a tree
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
随机推荐
- 0626-TP整理二(调试模式,空操作,跨控制器调用,跨方法跳转--redirect(),框架语法,创建model模型)
一.调试模式(入口文件:index.php) define('APP_DEBUG', true); //调试模式 define('APP_DEBUG', FALSE); //运行模式 开启日志信息 ...
- IDEA 激活方式
最新的IDEA激活方式 使用网上传统的那种输入网址的方式激活不了,使用http://idea.lanyus.com/这个网站提供的工具进行 1.进入hosts文件中:C:\Windows\System ...
- ACM_抢糖果
抢糖果 Time Limit: 2000/1000ms (Java/Others) Problem Description: 今天计实班的生活委员心情大好,在永诚超市狂购了好多好多糖果,好开心~o(∩ ...
- 图灵机(转自wiki)
图灵机(英语:Turing machine),又称确定型图灵机,是英国数学家艾伦·图灵于1936年提出的一种抽象计算模型,其更抽象的意义为一种数学逻辑机,可以看作等价于任何有限逻辑数学过程的终极强大逻 ...
- SCRIPT70: 没有权限
主要原因:iframe安全而引发的问题,浏览器中js是没有垮域访问的权限的.如果用到iframe首先确保不垮域,或者不用iframe以绕开这个问题. 另外在jquery的早期版本中如:jquery-1 ...
- mysqldump使用笔记
mysqldump备份简述 mysqldump可产生两种类型的输出文件,取决于是否选用 --tab=dir_name选项. 1.不使用 --tab=dir_name选项,mysqldump产生的数据文 ...
- jquery中有关cookie的使用简要说明
jquery.cookie.js 的配置 首先包含jQuery的库文件,在后面包含 jquery.cookie.js 的库文件. <script type="text/javascri ...
- STA之Concepts (1)
Static Timing Analysis is one of the many techniques available to verify the timing of a digital des ...
- java学习_5_23
Collection接口中定义的方法如下,所有继承自Collection接口的接口(List,Set)的实现类均实现了这些方法. List容器是有序.可重复的,常用的实现类:ArrayList,Lin ...
- Java基础(十)--static关键字
static关键字通常应用在字段.方法.静态块,还有冷门一点的内容:静态内部类.静态导入 static字段: static字段也就是静态变量,是属于类的,被所有的对象所共享,只有当类初次加载的时候保存 ...