Codeforces Round #272 (Div. 1) B 构造 math
http://www.codeforces.com/contest/477/problem/C
题目大意:给你n个集合,每个集合里面有四个数字,他们的gcd是k,输出符合条件的集合中m,m为集合中最大的数,且保证m要尽量小。
思路:由找规律可以得到集合的关系为1+6*k 2+6*k 3+6*k 5+6*k。
不过我的写法不是这样。。。(道理还是一样的)
//看看会不会爆int!数组会不会少了一维!
//取物问题一定要小心先手胜利的条件
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define mk make_pair
#define fi first
#define se second
const int maxn = + ;
bool vis[maxn];
int cnt, n, k, m;
int a[];
vector<int> v; int main(){
scanf("%d%d", &n, &k);
int tmp = ;
for (int i = ; i <= n; i++){
int t1 = tmp + k, t2 = tmp + * k, t3 = tmp + * k, t4 = tmp + * k;
tmp = t4 + k;
}
printf("%d\n", tmp - k);
tmp = ;
for (int i = ; i <= n; i++){
int t1 = tmp + k, t2 = tmp + * k, t3 = tmp + * k, t4 = tmp + * k;
tmp = t4 + k;
printf("%d %d %d %d\n", t1, t2, t3, t4);
}
return ;
}
Codeforces Round #272 (Div. 1) B 构造 math的更多相关文章
- Codeforces Round #272 (Div. 2) 题解
Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs time limit per test 1 second memory limit per ...
- Codeforces Round #272 (Div. 2) D. Dreamoon and Sets 构造
D. Dreamoon and Sets 题目连接: http://www.codeforces.com/contest/476/problem/D Description Dreamoon like ...
- 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) D. Dreamoon and Sets (思维 数学 规律)
题目链接 题意: 1-m中,四个数凑成一组,满足任意2个数的gcd=k,求一个最小的m使得凑成n组解.并输出 分析: 直接粘一下两个很有意思的分析.. 分析1: 那我们就弄成每组数字都互质,然后全体乘 ...
- Codeforces Round #272 (Div. 2) C. Dreamoon and Sums (数学 思维)
题目链接 这个题取模的时候挺坑的!!! 题意:div(x , b) / mod(x , b) = k( 1 <= k <= a).求x的和 分析: 我们知道mod(x % b)的取值范围为 ...
- Codeforces Round #272 (Div. 2)
A. Dreamoon and Stairs 题意:给出n层楼梯,m,一次能够上1层或者2层楼梯,问在所有的上楼需要的步数中是否存在m的倍数 找出范围,即为最大步数为n(一次上一级),最小步数为n/2 ...
- Codeforces Round #272 (Div. 2)AK报告
A. Dreamoon and Stairs time limit per test 1 second memory limit per test 256 megabytes input standa ...
- 题解——Codeforces Round #508 (Div. 2) T2 (构造)
按照题意构造集合即可 注意无解情况的判断 #include <cstdio> #include <algorithm> #include <cstring> #in ...
- Codeforces Round #272 (Div. 2) E. Dreamoon and Strings 动态规划
E. Dreamoon and Strings 题目连接: http://www.codeforces.com/contest/476/problem/E Description Dreamoon h ...
随机推荐
- 错误提示 Unsupported compiler 'com.apple.compilers.llvmgcc42' selected for architecture 'i386'
转自http://blog.csdn.net/cyuyanenen/article/details/51444974 警告提示:Invalid C/C++ compiler in target Cor ...
- 最全ajax函数
function ajax(method, url, data, success) { var xhr = null; try { xhr = new XMLHttpRequest(); } catc ...
- 学习笔记——命令模式Command
命令模式,将具体操作Receiver封在Command中,调用类只需要知道Command即可.
- POJ 2239 Selecting Courses
二分图的最大匹配.课程和时间可以看做二分图. #include<cstdio> #include<cstring> #include<cmath> #include ...
- 使用 VirtualBox 虚拟机在电脑上运行 Android 4.0 系统,让电脑瞬间变安卓平板
Ref: http://www.iplaysoft.com/android-v4-ics-for-virtualbox.html 随着 Android 手机的各种软件应用越来越多,很多没有购买的朋友都 ...
- git基本命令--远程
git clone: # clone到 <本地目录名> $ git clone <版本库的网址> <本地目录名> # 克隆版本库的时候,所使用的远程主机自动被Git ...
- hdu_5044_Tree(树链剖分)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5044 题意:给一棵树,在点和边上操作 题解:树链剖分,剖完后用树状数组维护即可,因为只有加减操作,连树 ...
- hdu_1728_逃离迷宫(bfs)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1728 题意:走迷宫,找最小的拐角 题解:对BFS有了新的理解,DFS+剪枝应该也能过,用BFS就要以拐 ...
- if语句,函数function
1.语句 一般分为顺序,分支和循环语句. if是分支语句 格式1:if(){} 若满足就进入花括号,若不满足就跳过 格式2:if(){}else(){}二选一.若if满足则else一定不执行,反之则 ...
- iOS应用程序内存查看工具
我要找的是一个可以检查应用程序中哪一个数组存贮的什么内容的工具. 网上搜到的工具名称是Allocations Instrument,后来一试发现不是我想要的.这还是一个后期调试阶段的内存检查工具. h ...