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 ...
随机推荐
- nginx安装与应用
一.nginx的安装与启动: 1.安装依赖库.nginx的一些模块需要依赖其他第三方库,通常有pcre库(perl compatible regular expression,perl兼容正则表达式, ...
- sql or 与and同时有时要注意
如果是一天sql语句中有or和and同时在 正确:where xxx=xx and (xxx=xx or xxx=xx) 错误:where xxx=xx and xxx=xx or xxx=xx (这 ...
- split分割函数
java.lang.string.split split 方法 将一个字符串分割为子字符串,然后将结果作为字符串数组返回. stringObj.split([separator,[limit]]) 参 ...
- svn hooks的使用demo
我是理论家: svn server端提供了Hooks Script.所谓钩子实际上是一种时间触发机制,是指当系统执行到某个特殊的事件时,触发我们预定义的动作,可以让我们在某些特定状态发生的时候做我们想 ...
- cPanel 安装方法
. 如何安装cPanel/WHM? 答:安装过程较长,建议使用screen或nohupscreen: yum -y install screen perl screen -S cpanel cd /h ...
- hdu_4823_Energy Conversion
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4823 题意:中文题,很清楚,要注意的是乘起来会爆int 题解: #include<cstdio& ...
- ios 烟花 火焰 雨水 雪花等特效属性
CAEmitterLayer *snowEmitter = [CAEmitterLayer layer]; //例子发射位置 snowEmitter.emitterPosition = CGPoint ...
- table导出到excel的两种方法
1. 用table2excel 的js文件,这种方法没有IE兼容性 需要在文件中导入 <script type="text/javascript" src="< ...
- JS调用OC方法
- (void)myMethod:(CDVInvokedUrlCommand*)command { NSString* echo = [command.arguments objectAtIndex: ...
- memcached的安装(server、client)、magent整合
声明:本编文章基于网络上的文章(90%),基本就是把我的安装步骤写一下,遇到问题记录一下 1.背景:项目需要多台服务器负载均衡,我们的应用有付费会员,不能让一个账号随便登陆,一个时间段只能一个账号,这 ...