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。

不过我的写法不是这样。。。(道理还是一样的)

  1. //看看会不会爆int!数组会不会少了一维!
  2. //取物问题一定要小心先手胜利的条件
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. #define LL long long
  6. #define ALL(a) a.begin(), a.end()
  7. #define pb push_back
  8. #define mk make_pair
  9. #define fi first
  10. #define se second
  11. const int maxn = + ;
  12. bool vis[maxn];
  13. int cnt, n, k, m;
  14. int a[];
  15. vector<int> v;
  16.  
  17. int main(){
  18. scanf("%d%d", &n, &k);
  19. int tmp = ;
  20. for (int i = ; i <= n; i++){
  21. int t1 = tmp + k, t2 = tmp + * k, t3 = tmp + * k, t4 = tmp + * k;
  22. tmp = t4 + k;
  23. }
  24. printf("%d\n", tmp - k);
  25. tmp = ;
  26. for (int i = ; i <= n; i++){
  27. int t1 = tmp + k, t2 = tmp + * k, t3 = tmp + * k, t4 = tmp + * k;
  28. tmp = t4 + k;
  29. printf("%d %d %d %d\n", t1, t2, t3, t4);
  30. }
  31. return ;
  32. }

Codeforces Round #272 (Div. 1) B 构造 math的更多相关文章

  1. Codeforces Round #272 (Div. 2) 题解

    Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs time limit per test 1 second memory limit per ...

  2. Codeforces Round #272 (Div. 2) D. Dreamoon and Sets 构造

    D. Dreamoon and Sets 题目连接: http://www.codeforces.com/contest/476/problem/D Description Dreamoon like ...

  3. 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 ...

  4. Codeforces Round #272 (Div. 2) D. Dreamoon and Sets (思维 数学 规律)

    题目链接 题意: 1-m中,四个数凑成一组,满足任意2个数的gcd=k,求一个最小的m使得凑成n组解.并输出 分析: 直接粘一下两个很有意思的分析.. 分析1: 那我们就弄成每组数字都互质,然后全体乘 ...

  5. Codeforces Round #272 (Div. 2) C. Dreamoon and Sums (数学 思维)

    题目链接 这个题取模的时候挺坑的!!! 题意:div(x , b) / mod(x , b) = k( 1 <= k <= a).求x的和 分析: 我们知道mod(x % b)的取值范围为 ...

  6. Codeforces Round #272 (Div. 2)

    A. Dreamoon and Stairs 题意:给出n层楼梯,m,一次能够上1层或者2层楼梯,问在所有的上楼需要的步数中是否存在m的倍数 找出范围,即为最大步数为n(一次上一级),最小步数为n/2 ...

  7. Codeforces Round #272 (Div. 2)AK报告

    A. Dreamoon and Stairs time limit per test 1 second memory limit per test 256 megabytes input standa ...

  8. 题解——Codeforces Round #508 (Div. 2) T2 (构造)

    按照题意构造集合即可 注意无解情况的判断 #include <cstdio> #include <algorithm> #include <cstring> #in ...

  9. Codeforces Round #272 (Div. 2) E. Dreamoon and Strings 动态规划

    E. Dreamoon and Strings 题目连接: http://www.codeforces.com/contest/476/problem/E Description Dreamoon h ...

随机推荐

  1. nginx安装与应用

    一.nginx的安装与启动: 1.安装依赖库.nginx的一些模块需要依赖其他第三方库,通常有pcre库(perl compatible regular expression,perl兼容正则表达式, ...

  2. sql or 与and同时有时要注意

    如果是一天sql语句中有or和and同时在 正确:where xxx=xx and (xxx=xx or xxx=xx) 错误:where xxx=xx and xxx=xx or xxx=xx (这 ...

  3. split分割函数

    java.lang.string.split split 方法 将一个字符串分割为子字符串,然后将结果作为字符串数组返回. stringObj.split([separator,[limit]]) 参 ...

  4. svn hooks的使用demo

    我是理论家: svn server端提供了Hooks Script.所谓钩子实际上是一种时间触发机制,是指当系统执行到某个特殊的事件时,触发我们预定义的动作,可以让我们在某些特定状态发生的时候做我们想 ...

  5. cPanel 安装方法

    . 如何安装cPanel/WHM? 答:安装过程较长,建议使用screen或nohupscreen: yum -y install screen perl screen -S cpanel cd /h ...

  6. hdu_4823_Energy Conversion

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4823 题意:中文题,很清楚,要注意的是乘起来会爆int 题解: #include<cstdio& ...

  7. ios 烟花 火焰 雨水 雪花等特效属性

    CAEmitterLayer *snowEmitter = [CAEmitterLayer layer]; //例子发射位置 snowEmitter.emitterPosition = CGPoint ...

  8. table导出到excel的两种方法

    1. 用table2excel 的js文件,这种方法没有IE兼容性 需要在文件中导入 <script type="text/javascript" src="< ...

  9. JS调用OC方法

    - (void)myMethod:(CDVInvokedUrlCommand*)command { NSString* echo = [command.arguments objectAtIndex: ...

  10. memcached的安装(server、client)、magent整合

    声明:本编文章基于网络上的文章(90%),基本就是把我的安装步骤写一下,遇到问题记录一下 1.背景:项目需要多台服务器负载均衡,我们的应用有付费会员,不能让一个账号随便登陆,一个时间段只能一个账号,这 ...