玲珑学院 1050 - array
Time Limit:3s Memory Limit:64MByte
Submissions:494Solved:155
2 array is an array, which looks like:
1,2,4,8,16,32,64......a1=1 ,a[i+1]/a[i]=2;
Give you a number array, and your mission is to get the number of subsequences ,which is 2 array, of it.
Note: 2 array is a finite array.

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int dp[],t,n,x,ans,pos;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
memset(dp,,sizeof(dp));
for(int i=;i<=n;i++)
{
scanf("%d",&x);
if(x==) dp[]++;
else
{
pos=;
while(!(x%))
{
x>>=;
pos++;
}
if(x== && dp[pos-]) dp[pos]=(dp[pos]+dp[pos-])%MOD;
}
}
ans=;
for(int i=;i<;i++)
ans=(ans+dp[i])%MOD;
printf("%d\n",ans);
}
return ;
}
玲珑学院 1050 - array的更多相关文章
- 玲珑学院-ACM比赛1014 - Absolute Defeat
1014 - Absolute Defeat Time Limit:2s Memory Limit:64MByte Submissions:257Solved:73 DESCRIPTION Eric ...
- 玲珑学院oj 1152 概率dp
1152 - Expected value of the expression Time Limit:2s Memory Limit:128MByte Submissions:128Solved:63 ...
- 玲珑学院1072 【DFS】
蛤蛤,略蠢. priority_queue 自定义优先级 和排序是反的 struct node { int x,y; friend bool operator< (node a,node b) ...
- 玲珑学院OJ 1023 - Magic boy Bi Luo with his excited math problem 树状数组暴力
分析:a^b+2(a&b)=a+b so->a^(-b)+2(a&(-b))=a-b 然后树状数组分类讨论即可 链接:http://www.ifrog.cc/acm/probl ...
- 玲珑学院OJ 1028 - Bob and Alice are playing numbers 字典树,dp
http://www.ifrog.cc/acm/problem/1028 题解处:http://www.ifrog.cc/acm/solution/4 #include <cstdio> ...
- 玲珑学院 1010 - Alarm
1010 - Alarm Time Limit:1s Memory Limit:128MByte DESCRIPTION Given a number sequence [3,7,22,45,116, ...
- 玲珑学院 1052 - See car
1052 - See car Time Limit:2s Memory Limit:64MByte Submissions:594Solved:227 DESCRIPTION You are the ...
- 玲珑学院 1014 Absolute Defeat
SAMPLE INPUT 3 2 2 2 1 1 5 1 4 1 2 3 4 5 4 10 3 1 2 3 4 SAMPLE OUTPUT 1 0 15 前缀和,每个元素都判断一下. #include ...
- PHP二维数组排序函数
PHP一维数组的排序可以用sort(),asort(),arsort()等函数,但是PHP二维数组的排序需要自定义. 以下函数是对一个给定的二维数组按照指定的键值进行排序,先看函数定义: functi ...
随机推荐
- NSStream 流式思想
流式思想的本质是将数据或信号看作流.流的管理者NSStream看作管道. 内容包含两方面: 1.流的建立:源.目的地: 2.流的管理:状态事件与数据事件. 本质上是建立联系.处理数据.处理状态.
- Mojo For Chromium Developers1
Mojo For Chromium Developers Overview This document contains the minimum amount of information neede ...
- HDU-1069 Monkey and Banana DAG上的动态规划
题目链接:https://cn.vjudge.net/problem/HDU-1069 题意 给出n种箱子的长宽高 现要搭出最高的箱子塔,使每个箱子的长宽严格小于底下的箱子的长宽,每种箱子数量不限 问 ...
- ArcGIS api for javascript——图层-创建WMS图层类型的图层
本例使用一个WMS端点创建了一个简单的动态图层.首先,代码声明一个新的类my.CityStatesRiversUSAWMSLayer,该类继承esri.layers.DynamicMapService ...
- C++里面关于虚函数的一些注意点
最后,总结一下关于虚函数的一些常见问题: 1) 虚函数是动态绑定的,也就是说,使用虚函数的指针和引用能够正确找到实际类的对应函数,而不是执行定义类的函数.这是虚函数的基本功能,就不再解释了. 2) 构 ...
- Java 8 时间日期库的20个使用演示样例
除了lambda表达式,stream以及几个小的改进之外,Java 8还引入了一套全新的时间日期API,在本篇教程中我们将通过几个简单的任务演示样例来学习怎样使用Java 8的这套API.Java对日 ...
- 线程池系列三:ThreadPoolExecutor讲解
三.一个用队列处理线程池例子 package demo; import java.util.Queue; import java.util.concurrent.ArrayBlockingQueue; ...
- vim基础学习之EX命令
:tabnew -创建新标签 :split(sp)-垂直分割窗口 如果没有打开新的文件,那么会打开原来窗口的文件 :vsplit(vsp)-水平分割窗口 如果没有打开新的文件,那么会打开原来窗口的文件 ...
- 30.angularJS第一个实例
转自:https://www.cnblogs.com/best/tag/Angular/ AngularJS 通过 ng-directives 扩展了 HTML. ng-app 指令定义一个 Angu ...
- 在spring-mybatis.xml 中配置pagehelper
maven导包:<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</ ...