codeforces437b
来源:互联网 发布:老虎为什么数量少 知乎 编辑:程序博客网 时间:2024/06/06 04:20
这个就是一个关于lowbit的东西,。,。,。,。,弱鸡。
当然我不知道我前几天写的为什么不对。反正可能是姿势不太对。
还有我发现一个事情。可能,好像,也许,和hlt的聚会,我发现。。。
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;const int N = 1e5 + 10;int a[N];int main(){ int sum , limit , tot = 0; scanf("%d %d",&sum , &limit); while(limit > 0 && sum > 0){ int x = limit & (-limit); if(sum >= x){ //printf("limit = %d ,x = %d\n",limit ,x); sum -= x; a[tot++] = limit; } limit--; } if(sum == 0){ printf("%d\n",tot); for(int i = 0 ; i < tot ; i++){ printf("%d ",a[i]); } } else{ printf("-1\n"); } return 0;}
0 0
- codeforces437b
- 报数游戏
- 完全卸载vs2013、vs2015的方法
- oracle 表碎片太多的处理办法
- CentOS下命令行终端的背景和shell命令提示符及其颜色
- Kafka文件存储机制那些事
- codeforces437b
- 清橙 A1485 Catch The Penguins 抓企鹅(张闻涛)
- LeetCode 485. Max Consecutive Ones
- 今天开通了CSDN微博,希望记录自己学习编程的点滴
- Topcoder SRM523-527(DIV2)
- 双向链表的C++实现
- 四、java常见日期函数
- linux学习笔记(系统管理命令)
- 这20个正则表达式,让你少写1,000行代码