Codeforces Round #272 (Div. 2) D. Dreamoon and Sets 构造
D. Dreamoon and Sets
题目连接:
http://www.codeforces.com/contest/476/problem/D
Description
Dreamoon likes to play with sets, integers and . is defined as the largest positive integer that divides both a and b.
Let S be a set of exactly four distinct integers greater than 0. Define S to be of rank k if and only if for all pairs of distinct elements si, sj from S, .
Given k and n, Dreamoon wants to make up n sets of rank k using integers from 1 to m such that no integer is used in two different sets (of course you can leave some integers without use). Calculate the minimum m that makes it possible and print one possible solution.
Input
The single line of the input contains two space separated integers n, k (1 ≤ n ≤ 10 000, 1 ≤ k ≤ 100).
Output
On the first line print a single integer — the minimal possible m.
On each of the next n lines print four space separated integers representing the i-th set.
Neither the order of the sets nor the order of integers within a set is important. If there are multiple possible solutions with minimal m, print any one of them.
Sample Input
1 1
Sample Output
5
1 2 3 5
Hint
题意
让你构造n个集合,使得每个集合里面都有四个元素,且两两元素之间的gcd都是k
让你使得其中最大数最小
题解:
其实就是样例的构造方法,这个得自己手玩一玩才行
代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    printf("%d\n",(n-1)*k*6+5*k);
    for(int i=0;i<n;i++)
        printf("%d %d %d %d\n",i*k*6+k,i*k*6+2*k,i*k*6+3*k,i*k*6+5*k);
}Codeforces Round #272 (Div. 2) D. Dreamoon and Sets 构造的更多相关文章
- Codeforces Round #272 (Div. 2)  D.Dreamoon and Sets  找规律
		D. Dreamoon and Sets Dreamoon likes to play with sets, integers and . is defined as the largest p ... 
- Codeforces Round #272 (Div. 2)  D. Dreamoon and Sets (思维 数学  规律)
		题目链接 题意: 1-m中,四个数凑成一组,满足任意2个数的gcd=k,求一个最小的m使得凑成n组解.并输出 分析: 直接粘一下两个很有意思的分析.. 分析1: 那我们就弄成每组数字都互质,然后全体乘 ... 
- Codeforces Round #272 (Div. 2) E. Dreamoon and Strings 动态规划
		E. Dreamoon and Strings 题目连接: http://www.codeforces.com/contest/476/problem/E Description Dreamoon h ... 
- Codeforces Round #272 (Div. 2) B. Dreamoon and WiFi dp
		B. Dreamoon and WiFi 题目连接: http://www.codeforces.com/contest/476/problem/B Description Dreamoon is s ... 
- Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs 水题
		A. Dreamoon and Stairs 题目连接: http://www.codeforces.com/contest/476/problem/A Description Dreamoon wa ... 
- Codeforces Round #272 (Div. 2) E. Dreamoon and Strings dp
		题目链接: http://www.codeforces.com/contest/476/problem/E E. Dreamoon and Strings time limit per test 1 ... 
- Codeforces Round #272 (Div. 1) A. Dreamoon and Sums(数论)
		题目链接 Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occa ... 
- Codeforces Round #272 (Div. 2)-C. Dreamoon and Sums
		http://codeforces.com/contest/476/problem/C C. Dreamoon and Sums time limit per test 1.5 seconds mem ... 
- Codeforces Round #272 (Div. 2)-B. Dreamoon and WiFi
		http://codeforces.com/contest/476/problem/B B. Dreamoon and WiFi time limit per test 1 second memory ... 
随机推荐
- HDU 1730 类NIM模型
			两者间的间距就是可取石子数,因为对于行内黑白相连的局面该子游戏已经结束了因为此时不管先手再怎么移都是必败,SG=0的终止态 /** @Date : 2017-10-14 21:46:21 * @Fil ... 
- 那些年的 网络通信之 TCP/IP 传输控制协议 ip 加 端口 ---
			/* 一个文本小写转换为大写的小程序,当客户端从键盘录入一串字符串发送到服务端服务端转换为大写返回给客户端 */ import java.io.*; import java.net.*; class ... 
- javascript类式继承最优版
			直接看实例代码: <!doctype html> <html lang="en"> <head> <meta charset=" ... 
- Android Studio 新建drawable-hdpi、drawable-mdpi等
			在不同的模式“Project” / “Android”的文件夹中查看文件夹.如果文件夹丢失,您可以轻松添加它们. 1.在“res”文件夹上右键“New”->”Android Resource D ... 
- 理解 Memory barrier(内存屏障)【转】
			转自:http://name5566.com/4535.html 参考文献列表:http://en.wikipedia.org/wiki/Memory_barrierhttp://en.wikiped ... 
- MySQL乱码问题以及utf8mb4字符集
			MySQL乱码问题以及utf8mb4字符集 1.乱码 推荐大家看 深入MySQL字符集设置 ,区分检查client端.server端的编码:最简单暴力的方式,是在所有的环节都显式明确的指定相同的编码, ... 
- Restful对于URL的简化
			REST是英文representational state transfer(表象性状态转变)或者表述性状态转移,它是web服务的一种架构风格.使用HTTP,URI,XML,JSON,HTML等广泛流 ... 
- day17作业
			1.java.util 2.队列先进先出,栈堆先进后出 3.链表 4.LinkedList 5.TreeSet 6.Comparable 7.Map 8.next() 1.AC 2.A ... 
- Flask 目录
			flask入门 flask 源码剖析 Flask session Flask form 
- 如何用prometheus监控k8s集群中业务pod的metrics
			一般,我们从网上看到的帖子和资料, 都是用prometheus监控k8s的各项资源, 如api server, namespace, pod, node等. 那如果是自己的业务pod上的自定义metr ... 
