587A
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
const int maxn=1e7+;//数组必须开大些,因为数据过大时2^n会超过1e6;
int w[maxn];
int n,ans;
int main()
{
while(~scanf("%d",&n))
{
memset(w,,sizeof(w));
ans=;
for(int i=;i<n;i++)
{
int x;
scanf("%d",&x);
w[x]++; //x代表幂
} for(int i=;i<maxn;i++) //合并;原理:2^n+2^n=2^(n+1);
{
w[i]+=(w[i-]/);
w[i-]%=;
}
for(int i=;i<maxn;i++)
ans+=w[i];
printf("%d\n",ans);
}
return ;
}
587A的更多相关文章
- Duff and Weight Lifting - 587A
题目大意:某个人训练举重,他每次可以举起来2^wi的重量,不过这个人比较懒所以他想尽量减少训练的次数,如果所有的训练重量2^a1 +2^a2+....2^ak = 2^x,那么这些重量可以一次性训练( ...
- CodeForces 587A
题目链接: http://codeforces.com/problemset/problem/587/A 题意: 输入n个数,在这n个数中,寻找有多少个数不能消除掉 消除方法:两个相同的数消除后,生成 ...
- Codeforces Round #326 div2
Problem_A(588A): 题意: Duff 很喜欢吃肉, 每天都要吃,然而她又懒得下楼. 可以买很多放在家里慢慢吃.然而肉价每天都在变化,现给定一个n, 表示有多少天,然后第i天吃ai kg的 ...
- 谈谈 iOS 中图片的解压缩
原文 对于大多数 iOS 应用来说,图片往往是最占用手机内存的资源之一,同时也是不可或缺的组成部分.将一张图片从磁盘中加载出来,并最终显示到屏幕上,中间其实经过了一系列复杂的处理过程,其中就包括了对图 ...
- 【转】谈谈 iOS 中图片的解压缩
转自:http://blog.leichunfeng.com/blog/2017/02/20/talking-about-the-decompression-of-the-image-in-ios/ ...
- Codeforces Round #326(Div2)
CodeForces 588A 题意:Duff喜欢吃肉,想在接下来的n天,每天都有Ai斤肉吃,但每一天肉的单价Pi不定,肉 可以保存不过期,现已知n天每天肉的斤数Ai,以及单价Pi,为了使每天都 ...
- iOS 图片的解压缩
一.图片加载的工作流 概括来说,从磁盘中加载一张图片,并将它显示到屏幕上,中间的主要工作流如下: 假设我们使用 +imageWithContentsOfFile: 方法从磁盘中加载一张图片,此时的图片 ...
随机推荐
- JSP公用COMMON文件
head.jsp: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" ...
- 【leetcode】Minimum Depth of Binary Tree (easy)
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...
- 【leetcode】Count and Say (easy)
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...
- 【leetcode】Best Time to Buy and Sell 3 (hard) 自己做出来了 但别人的更好
Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...
- php字符串处理函数相关操作
<?php//获取tech和98426这两个字符串
- August 30th 2016 Week 36th Tuesday
If you keep on believing, the dreams that you wish will come true. 如果你坚定信念,就能梦想成真. I always believe ...
- php提示 Notice: Use of undefined constant name - assumed
我们知道php在数组中写变量有二几种方法,我们出现这种提示就是你写成了[name]这种所以会有Notice: Use of undefined constant name - assumed name ...
- JAVA基础学习之final关键字、遍历集合、日期类对象的使用、Math类对象的使用、Runtime类对象的使用、时间对象Date(两个日期相减)(5)
1.final关键字和.net中的const关键字一样,是常量的修饰符,但是final还可以修饰类.方法.写法规范:常量所有字母都大写,多个单词中间用 "_"连接. 2.遍历集合A ...
- Python 打开目录与指定文件
Python打开外部文件有很多方法, os.popen打开外部程序,但发现只能打开文件所在目录的文件 os.system可打开外部文件os.system(command) command 要执行的命令 ...
- 【转载】Pyqt 编写的俄罗斯方块
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function from __future__ ...