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 ...
随机推荐
- 3.Perl 多线程:Threads(exit thread_only)
还可以在导入threads模块时设置: use threads ('exit' => 'thread_only');
- Flask -- 请求、上传文件、Cookies
请求对象 from flask import request request.method #值为form表单提交的method 'POST'. 'GET'等 #如果值为'POST'或'PUT',则可 ...
- android 布局页面文件出错故障排除Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V
今天在看布局文件的时候出现 android 布局页面文件出错故障排除Exception raised during rendering: java.lang.System.arraycopy([CI[ ...
- POJ 3417 Network
每条额外的边加入到图中,会导致树上一条路径成环,假设没有其余边,那么要将新图分成两部分,如果想删一条成环路径上的边,那么必须把这条额外边也删除. 因此每条额外边加入时,只需将环上的边+1.最后看看每条 ...
- unknow type name 'off64_t'
或者 错误"error: 'off64_t' does not name a type" MinGW的bug,使用-std=c++11, 有可能出现, 修改{MinGW dir} ...
- 无法识别的配置节 system.serviceModel
也是从网上四处搜来的答案,的确是解决了问题 不知道是不是补丁更新的原因,之前运行好的程序,突然就不行了, 一开始,运行直接就闪退了,在事件查看器里,也看不到具体的错误信息,幸亏是cmd的程序,所以 , ...
- 命令窗口修改编码,CMD编码修改方法
cmd中的编码方式为ANSI,若中文不是此编码方式则会出现乱码.作为程序员,会经常使用命令窗口查看执行日志,但是有时编码格式不对,大部分都是UTF8,在网上搜索了不少方法,很多没什么用,在这里教一个具 ...
- cpanel 定时运行sh/php
php -q /home/用户/public_html/cron.php -------------------php格式 /home/用户/public_html ...
- Web开发人员不要错过的60款用户界面设计工具(中)
21. Dojo Dojo是一个用javascript语言实现的开源DHTML UI工具包,可实现高性能的桌面和移动应用程序开发,在国内亦有大量忠实用户. 22. Fivesecondtest Fiv ...
- apt-get 依赖修复
apt-get cleanapt-get update apt-get -f install dpkg --configure -a