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

最新文章

  1. NOIP 考前 计算几何练习
  2. Ajax省市区无刷新单表联动查询
  3. 第三章 对象(JavaScript:语言精粹)
  4. mysql 查看 索引
  5. BoneCP主要配置参数
  6. 通过分析WP的代码来学习PHP。1
  7. Linux Java开发坏境搭建,Ubuntu-jdk+tomcat+eclipse+svn 包安装详细操作
  8. CentOS MariaDB 安装和配置
  9. 在exe运行界面按右键(不用按鼠标右键)
  10. idea Cannot Resolve Symbol 问题解决
  11. Docker部署Zookeeper容器
  12. 【紫书】 Unix ls UVA - 400 模拟
  13. 【转】每天一个linux命令(21):find命令之xargs
  14. Linux上查看造成IO高负载的进程
  15. boost::asio基本使用
  16. Tomcat服务器学习和使用(二)
  17. Word中插入英文格式的算法流程
  18. 2018.6.18 MyEclipse导入jquery-1.8.0.min.js等文件报错的解决方案
  19. selinue引起的ssh连接错误
  20. 程序员成长的四个简单技巧,你 get 了吗?

热门文章

  1. hibernate 命名策略
  2. 【iOS】UIImage 等比率缩放
  3. 利用dockerfile 安装一个tomcat7
  4. Redis Sentinel基本实现原理
  5. Spring的依赖注入和管理Bean
  6. MobaXterm:远程终端登录软件封神选手
  7. NOIP 2018旅行题解
  8. SDS模块
  9. SpringBoot-Admin的使用
  10. 从零开发一款自己的小程序UI组件库(二)