【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 ...
随机推荐
- css实现左边div固定宽度,右边div自适应撑满剩下的宽度
(1)使用float <div class="use-float"> <div></div> <div></div> & ...
- Vue.js实战 5.5章 购物车
<!DOCTYPE html> <html lang="en"> <head> <title>购物车示例</title> ...
- P3626 [APIO2009]会议中心
传送门 好迷的思路-- 首先,如果只有第一问就是个贪心,排个序就行了 对于第二问,我们考虑这样的一种构造方式,每一次都判断加入一个区间是否会使答案变差,如果不会的话就将他加入别问我正确性我不会证 我们 ...
- 【杂文】C++头文件加速
[杂文]C++头文件加速 骚年,冲钱送开挂哦,可以助你超神于OI战场 如果你发现你的暴力超时了的话,可以尝试用一下头文件加速,说不定就过了呢! #pragma once//只编译一次 #pragma ...
- [51nod]1678 lyk与gcd(莫比乌斯反演)
题面 传送门 题解 和这题差不多 //minamoto #include<bits/stdc++.h> #define R register #define pb push_back #d ...
- http2及server push
本文主要研究下java9+springboot2+undertow2启用http2及server push maven <parent> <groupId>org.spri ...
- Kali Linux的介绍
Kali Linux是什么? Kali Linux是一个渗透测试平台兼安全审计平台,它集成了多款漏洞检测.目标识别和漏洞利用工具. Kali Linux是专门用于渗透测试的Linux操作系统:基于De ...
- Python(1)-第一天
PTVS下载地址:https://pytools.codeplex.com/releases/view/109707 Python下载地址:https://www.python.org/downloa ...
- Linux shell命令之cat
cat:查看文件的内容.连接文件.创建一个或多个文件和重定向输出到终端或文件 用法:cat [选项] [文件] 1. $ cat hello.txt 显示hello.txt文本文件中的内容 2. $ ...
- [ USACO 2007 FEB ] Lilypad Pond (Gold)
\(\\\) \(Description\) 一张\(N\times M\)的网格,已知起点和终点,其中有一些地方是落脚点,有一些地方是空地,还有一些地方是坏点. 现在要从起点到终点,每次移动走日字\ ...