【链接】 我是链接,点我呀:)

【题意】

题意

【题解】

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的更多相关文章

  1. 【codeforces 716D】Complete The Graph

    [题目链接]:http://codeforces.com/problemset/problem/716/D [题意] 给你一张图; 这张图上有一些边的权值未知; 让你确定这些权值(改成一个正整数) 使 ...

  2. Codeforces 1009D:Relatively Prime Graph

    D. Relatively Prime Graph time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  3. 【Codeforces 340D】Bubble Sort Graph

    [链接] 我是链接,点我呀:) [题意] 让你根据冒泡排序的规则 建立一张图 问你这张图的最大独立子集的大小 [题解] 考虑a[i]会和哪些点连边? 必然是在a[i]左边且比它大的数字以及在a[i]右 ...

  4. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  5. 【Azure Developer】使用Microsoft Graph API 批量创建用户,先后遇见的三个错误及解决办法

    问题描述 在先前的一篇博文中,介绍了如何使用Microsoft Graph API来创建Azure AD用户(博文参考:[Azure Developer]使用Microsoft Graph API 如 ...

  6. 【codeforces 755E】PolandBall and White-Red graph

    [题目链接]:http://codeforces.com/contest/755/problem/E [题意] 给你n个节点; 让你在这些点之间接若干条边;构成原图(要求n个节点都联通) 然后分别求出 ...

  7. 【34.57%】【codeforces 557D】Vitaly and Cycle

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. 【27.91%】【codeforces 734E】Anton and Tree

    time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. 【30.36%】【codeforces 740D】Alyona and a tree

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. angularJs模版注入的两种方式

    一,声名式注入 1:app.js: var myApp = angular.module("myApp",["ngRoute"]); 2:controller. ...

  2. 几个SQL小知识(转)

    原文地址:http://www.cnblogs.com/wuguanglei/p/4205976.html 写在前面的话:之前做的一个项目,数据库及系统整体构架设计完成之后,和弟兄们经过一段时间的编码 ...

  3. 获取openid [微信小程序]

    public function wxapi(){ $data=$this->requestdata(); if(!$data['code']) exit(json_encode(array('s ...

  4. ACM_递推题目系列之一涂色问题(递推dp)

    递推题目系列之一涂色问题 Time Limit: 2000/1000ms (Java/Others) Problem Description: 有排成一行的n个方格,用红(Red).粉(Pink).绿 ...

  5. 解决:阿里云ECS上启动tomcat后,第一次访问时间特别长

    Re在ECS上启动tomcat后,第一次访问时间特别长      2017-04-25 10:16:04 INFO com.world.socket.ServerSocketListener  25- ...

  6. Visual Studio 生成项目时脚本执行

    项目属性 - 生成事件 项目生成前:预先生成事件命令行: 项目生成后:后期生成事件命令行:例:copy $(ProjectDir)Reference\sms_cfg.ini $(TargetDir) ...

  7. cocos2dx在windows下搭建环境android报错

    报错:Program bash is not found in PATH   (如果按照我的方法来的话是没有这个错误的,我之前用别的方法的时候有但是后来还是没解决,写出来放到这里做参考吧) 参考原文: ...

  8. can't set blob value on that column

    MySQL_Prepared_Statement::setBlob: can't set blob value on that column, MySQL error code:0, SQLState ...

  9. PHP常见问题总结

    1.为什么会出现这种情况?端口什么的都设置正确了. 解决方法: 请将本机的IIS服务关闭,开启Apache服务.IIS服务的关闭方法可参见 https://jingyan.baidu.com/arti ...

  10. android开发小内容

    EditText弹出输入数字:android:inputType="phone"