51nod 搬货物
来源:互联网 发布:php兼职 编辑:程序博客网 时间:2024/05/17 04:37
这个题目很简单 用2^i进位就好了 但是让卡住了 原因是得用输入挂 。。。。。学习了一波
#include <iostream>#include <algorithm>using namespace std;int arr[1002000];template <class T>inline void scan_d(T &ret){ char c; ret=0; while((c = getchar()) < '0' || c > '9'); while(c >= '0' && c <= '9') { ret = ret * 10 + (c - '0'), c = getchar(); }}int main(){ int n; cin>>n; while(n--) { int buff; scan_d(buff); arr[buff]++; } int startpoint; for(int i=0;i<=1e6+1000;++i)//1e6后面一定要加足够的数量保证进位能够成功!刚开始我就写了1e6+5结果不够 有两个wa点 { int buff=arr[i]/2; arr[i]%=2; arr[i+1]+=buff; if(arr[i]) startpoint=i; } int cnt=0; for(int i=startpoint;i>=0;i--) { if(arr[i]) cnt++; } cout<<cnt<<endl; return 0;}
0 0
- 51nod 搬货物
- 51NOD 1596 搬货物
- 51Nod-1596-搬货物
- 51nod 1596 搬货物
- 51nod 1596 搬货物
- 51nod 1596 搬货物
- 51Nod 1596 搬货物
- 51nod-1596 搬货物
- 51Nod 1596 搬货物
- 51nod-1596 搬货物
- 51nod 1596 搬货物
- 51Nod 1596 搬货物
- 51nod 1596 搬货物
- 51Nod 1596 搬货物
- 51nod 1596 搬货物
- 51nod 1596 搬货物
- 51nod 1596 搬货物
- 51nod 1596 搬货物
- 找了点快捷键
- CoordinatorLayout + AppBarLayout 实现标题栏置顶
- 文件上传 content-type:application/json System.Web.HttpContext.Current.Request.InputStream 读取不到数据
- 4~20mA电流输出芯片XTR111完整电路
- 序列化与反序列
- 51nod 搬货物
- 某协议接收响应模块
- vim安装Typescript语法高亮
- Hadoop运维(3) Spark集群部署
- [姿态预测] Flowing ConvNets for Human Pose Estimation in Videos
- 移动应用瘦身学习总结 (Android&iOS)
- Java之——Web项目中DLL文件动态加载方法
- HRD(hypothetical reference decode)
- [姿态预测] Advancing Human Pose and Gesture Recognition章节 Pose Estimation with a Deep Heatmap Network