【CF 1059C】 Sequence Transformation 数学
C. Sequence Transformation:http://codeforces.com/contest/1059/problem/C
题意
给你一个n,第一次输出1~n个数的gcd,然后你可以任意删除1~n中的数字,然后输出剩下n-1个数的gcd,再删一个数...,最后就是输出n个gcd值对吧。
要求输出的数列字典序最大。
思路
首先对于一个n,为了使得数列字典序最大,肯定是越早输出2越好,所以前面先把所有的奇数去掉,前(n+1)/2 个数肯定也就是1,那么剩下的偶数呢,可以先对这些偶数除2,同理把其中的奇数删掉,输出2(因为这是除以了2的),然后再对剩下的偶数除2,做相同的操作。
//#pragma GCC optimize(3)
//#pragma comment(linker, "/STACK:102400000,102400000") //c++
#include <algorithm>
#include <iterator>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <cctype>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>
using namespace std; #define lson (l , mid , rt << 1)
#define rson (mid + 1 , r , rt << 1 | 1)
#define debug(x) cerr << #x << " = " << x << "\n";
#define pb push_back
#define pq priority_queue typedef long long ll;
typedef unsigned long long ull; typedef pair<ll ,ll > pll;
typedef pair<int ,int > pii;
typedef pair<int ,pii> p3;
//priority_queue<int> q;//这是一个大根堆q
//priority_queue<int,vector<int>,greater<int> >q;//这是一个小根堆q
#define fi first
#define se second
//#define endl '\n' #define OKC ios::sync_with_stdio(false);cin.tie(0)
#define FT(A,B,C) for(int A=B;A <= C;++A) //用来压行
#define REP(i , j , k) for(int i = j ; i < k ; ++i)
//priority_queue<int ,vector<int>, greater<int> >que; const ll mos = 0x7FFFFFFFLL; //
const ll nmos = 0x80000000LL; //-2147483648
const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3fLL; //
const double PI=acos(-1.0); template<typename T>
inline T read(T&x){
x=;int f=;char ch=getchar();
while (ch<''||ch>'') f|=(ch=='-'),ch=getchar();
while (ch>=''&&ch<='') x=x*+ch-'',ch=getchar();
return x=f?-x:x;
}
// #define _DEBUG; //*//
#ifdef _DEBUG
freopen("input", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
/*-----------------------show time----------------------*/ int main(){
int n; scanf("%d", &n);
int res = ;
while(n>){
for(int i=; i<=(n+)/; i++)printf("%d ", res);
res *= ;
n/=;
}
if(n==)printf("%d\n", res);
else if(n==)printf("%d %d\n", res, res * );
else printf("%d %d %d\n", res , res, res * );
return ;
}
cf1059C
【CF 1059C】 Sequence Transformation 数学的更多相关文章
- [CodeForces]1059C Sequence Transformation
构造题. 我递归构造的,发现如果N>3的话就优先删奇数,然后就把删完的提取一个公约数2,再重复操作即可. 具体原因我觉得是因为对于一个长度大于3的序列,2的倍数总是最多,要令字典序最大,所以就把 ...
- CodeForces - 1059C Sequence Transformation (GCD相关)
Let's call the following process a transformation of a sequence of length nn. If the sequence is emp ...
- codeforces 1059C. Sequence Transformation【构造】
题目:戳这里 题意:有1,2,3...n这n个数,求一次这些数的gcd,删去一个数,直到剩下一个数为止.输出这n个gcd的最大字典序. 解题思路:一开始的gcd肯定是1,要让字典序最大,我们可以想到下 ...
- CF1059C Sequence Transformation 题解
这几天不知道写点什么,状态也不太好,搬个题上来吧 题意:给定一个数n,设一个从1到n的序列,每次删掉一个序列中的数,求按字典序最大化的GCD序列 做法:按2的倍数找,但是如果除2能得到3的这种情况要特 ...
- Codeforces Round #514 (Div. 2) C. Sequence Transformation(递归)
C. Sequence Transformation 题目链接:https://codeforces.com/contest/1059/problem/C 题意: 现在有1~n共n个数,然后执行下面操 ...
- hdu 5312 Sequence(数学推导+线性探查(两数相加版))
Problem Description Today, Soda has learned a sequence whose n-th (n≥) item )+. Now he wants to know ...
- Codeforces Round #514 (Div. 2) C. Sequence Transformation 思维构造
题意 给出一个1-n的集合 gcd 集合里面的所有数 得到的 一个 数 然后自己选择删去一个数 要使得到的数 构成的数列 的字典序最大 思路: gcd所有数 那gcd得到的数肯定要小于数 ...
- HDU 1041 Computer Transformation 数学DP题解
本题假设编程是使用DP思想直接打表就能够了. 假设是找规律就须要数学思维了. 规律就是看这些连续的0是从哪里来的. 我找到的规律是:1经过两次裂变之后就会产生一个00: 00经过两次裂变之后也会产生新 ...
- Codeforces--622A--Infinite Sequence(数学)
Infinite Sequence Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:26214 ...
随机推荐
- 后台post注入爆密码
后台登陆框post注入按照注入的方式属于post,和前台搜索型post注入.文本框注入类似,由于目前主流的注 入工具除了穿山甲等较新工具以外几乎都是get注入,尤其是对于这种后台账户型post注入式无 ...
- 定时器任务django-crontab的使用【静态化高频率页面,增加用户体验】【系统的定时器,独立于项目执行】【刘新宇】
页面静态化 思考: 网页的首页访问频繁,而且查询数据量大,其中还有大量的循环处理. 问题: 用户访问首页会耗费服务器大量的资源,并且响应数据的效率会大大降低. 解决: 页面静态化 1. 页面静态化介绍 ...
- 基于opencv,开发摄像头播放程序
前言 Windows下实现摄像视频捕捉有多种实现方式:各种方式的优劣,本文不做对比.但是,opencv是一款老牌开发库,在图像处理领域声名显赫.采用opencv来处理摄像视频,在性能和稳定性上,是有保 ...
- 超全的 Vue 开源项目合集,签收一下
超全的 Vue 开源项目合集,签收一下 xiaoge2016 前端开发 1周前 作者:xiaoge2016 链接: https://my.oschina.net/u/3018050/blog/2049 ...
- Meta 用法汇总
本文引自: http://blog.csdn.net/MR_LP/article/details/53607087 什么是 meta ? meta 是html语言head区的一个辅助性标签.也许你认为 ...
- 工作中常见的五种技术leader
力不从心型 在工作中有种技术leader,总认为自己是最好的.在方案设计的时候,自己有一种方案,下属有一种方案.leader非要别人听他的.如果两种方案没有优劣之分,比较建议的做法是让真正实施的人按照 ...
- docker/kubernetes国内源/镜像源解决方式
最近在使用kubeadm时,被各种连接不上搞到崩溃.费了很多力气,基本都解决了.这里统一整理了国内的一些镜像源,apt源,kubeadm源等,以便查阅. 国内镜像源 Azure China提供了目前用 ...
- Map集合的遍历(利用entry接口的方式)
核心思想: 调用map集合中的方法entrySet()将集合中的映射关系存放在Set集合中. 迭代Set集合 获取出的Set集合的元素是映射关系对象 通过映射关系对象方法的getKey(),getVa ...
- 为何你还不懂得如何使用Python协程
关于我 一个有思想的程序猿,终身学习实践者,目前在一个创业团队任team lead,技术栈涉及Android.Python.Java和Go,这个也是我们团队的主要技术栈. Github:https:/ ...
- C++通过宏定义判断操作系统及编译器
INTRODUCTION: C++的编译环境千奇百怪,很多时候一些代码在某些编译环境下可用,一旦移到其他环境下,就会干脆Compile Error 对此,我们可以使用C++的宏定义来判断操作系统,从而 ...