【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 ...
随机推荐
- ionic安卓打包apk--安卓签名
上周项目上线,在网上看了看打包的博客,感觉不是很清晰我自己来总结下 首先,我们在项目的根目录下 build android apk 的时候执行的命令一定要是 ionic build android - ...
- 慕课网4-2 编程练习:jQuery祖先后代选择器小案例
4-2 编程练习 结合所学的祖先后代选择器,实现如下图所示效果 任务 (1)使用祖先后代选择器将第二段文字背景色变成红色 (2)使用jQuery的.css()方法设置样式,语法css('属性 '属性值 ...
- Android 性能优化(27)*zipalign让apk数据对齐,运行更快。
1.zipalign 简介 zipalign is an archive alignment tool that provides important optimization to Android ...
- CSS之选择符、链接、盒子模型、显示隐藏元素
<html> <head> <meta charset="utf-8"> <title>选择符.链接.盒子模型.显示隐藏元素< ...
- multiprocessing的进程通信Pipe和Queue
pipe管道,2个进程通信,允许单项或者双向,multiprocessing.Pipe(duplex=False)为单项,默认双向 示例: from multiprocessing import Pr ...
- [转]ASP .NET MVC 之Entity Framework- code first
本文转自:http://www.cnblogs.com/tomin/archive/2012/02/29/MVC_EntityFramework.html 最近,用到了ASP.NET MVC Ent ...
- sql server 行转列 要注意的问题 pivot
select * from ( select mvqr.VoteQuestionId,mvqr.AnswerSolution from JY_MemberVoteQuestionRef as ...
- netty 引用计数器 ,垃圾回收
netty 引用计数器 ,垃圾回收 https://blog.csdn.net/u013851082/article/details/72170065 Netty之有效规避内存泄漏 https://w ...
- 【工具】Webpack
远程仓库建立 码云创建组织项目 git clone ssh 切换到主分支mmall-fe后git remote add origin ssh git pull origin master把master ...
- CSS布局整理
目录 常用居中方法 水平居中 垂直居中 单列布局 二列&三列布局 float+margin position+margin 圣杯布局(float+负margin) 双飞翼布局(float+负m ...