【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 ...
随机推荐
- 【WIP_S3】链表
创建: 2017/12/26 完成: 2018/01/14 [TODO] S4, S5, S14来处理动态数组 CAF8A81B790F [github 地址]传送门 链表的定义 ...
- JavaSwing输入对话框,点击取消抛出异常的解决方法
在做产品管理系统的时候,遇到一个问题: 在得到一个输入框对话框的时候 String textPrice = JOptionPane.showInputDialog("请输入要调整的价格增(减 ...
- P3222 [HNOI2012]射箭
传送门 黄学长的代码好清楚啊--大概搞明白半平面交是个什么玩意儿了-- 设抛物线 \[y=ax^2+bx\] 则 \[y1<=ax1^2+bx1<=y2\] \[ax1^2+bx1> ...
- 洛谷 P1045 麦森数
题目描述 形如2^{P}-1的素数称为麦森数,这时P一定也是个素数.但反过来不一定,即如果P是个素数,2^{P}-1不一定也是素数.到1998年底,人们已找到了37个麦森数.最大的一个是P=30213 ...
- hdu5924Mr. Frog’s Problem
Mr. Frog's Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- ACM_四数之和
四数之和 Time Limit: 2000/1000ms (Java/Others) Problem Description: 有n个不同的整数,判断能否从中选4次,4个数和刚好为m.数字可重复选取. ...
- 数据传递-------@PathVariable
package com.wh.handler; /** * 通过@PathVariable可以绑定占位符参数到方法参数中,例如 * @PathVariable("userId") ...
- 02—IOC实现项目中的解耦
- 初窥Android Studio
Android Studio 是一个Android集成开发工具,基于IntelliJ IDEA. 类似 Eclipse ADT,Android Studio 提供了集成的 Android 开发工具用于 ...
- 手机页面操作栏的创建及WebFont的使用
一.手机界面底部操作栏的创建. <style> .opers{ position:absolute; bottom:0px; left:0px; right:0px; height:3re ...