Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)
Alice and Bob
Time Limit: 1000ms Memory limit: 65536K
题目描述
Alice and Bob like playing games very much.Today, they introduce a new game.
There is a polynomial like this: (a0*x^(2^0)+1) * (a1 * x^(2^1)+1)*.......*(an-1 * x^(2^(n-1))+1). Then Alice ask Bob Q questions. In the expansion of the Polynomial, Given an integer P, please tell the coefficient of the x^P.
Can you help Bob answer these questions?
输入
For each case, the first line contains a number n, then n numbers a0, a1, .... an-1 followed in the next line. In the third line is a number Q, and then following Q numbers P.
1 <= T <= 20
1 <= n <= 50
0 <= ai <= 100
Q <= 1000
0 <= P <= 1234567898765432
输出
示例输入
1
2
2 1
2
3
4
示例输出
2
0
提示
来源
分析
恍然大悟,大难题秒变水题。
示例程序
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cstring>
using namespace std; int main()
{
int T;
scanf("%d",&T);//测试组数
while(T--)
{
int a[];//存储系数
memset(a,,sizeof(a));//全部初始化为零
int n,q;
scanf("%d",&n);
for(int i=;i<n;i++)
scanf("%d",&a[i]);
scanf("%d",&q);//查询次数
while(q--)
{
long long p;
scanf("%lld",&p);
long long sum=,i=;
while(p)//化为二进制
{
if(p%==)
sum*=a[i];
if(sum>)
sum%=;
i++;
p/=;
}
printf("%lld\n",sum);
}
}
return ;
}
Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)的更多相关文章
- 2013年山东省第四届ACM大学生程序设计竞赛-最后一道大水题:Contest Print Server
点击打开链接 2226: Contest Print Server Time Limit: 1 Sec Memory Limit: 128 MB Submit: 53 Solved: 18 [Su ...
- sdut Mountain Subsequences 2013年山东省第四届ACM大学生程序设计竞赛
Mountain Subsequences 题目描述 Coco is a beautiful ACMer girl living in a very beautiful mountain. There ...
- 2013年山东省第四届ACM大学生程序设计竞赛 Alice and Bob
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 题目描述 Alice and Bob like playing games very ...
- 2013年山东省第四届ACM大学生程序设计竞赛E题:Alice and Bob
题目描述 Alice and Bob like playing games very much.Today, they introduce a new game. There is a polynom ...
- 2013年山东省第四届ACM大学生程序设计竞赛J题:Contest Print Server
题目描述 In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your source code ...
- 山东省第四届ACM大学生程序设计竞赛解题报告(部分)
2013年"浪潮杯"山东省第四届ACM大学生程序设计竞赛排名:http://acm.upc.edu.cn/ranklist/ 一.第J题坑爹大水题,模拟一下就行了 J:Contes ...
- UPC 2224 / “浪潮杯”山东省第四届ACM大学生程序设计竞赛 1008 Boring Counting 主席树
Problem H:Boring Counting Time Limit : 6000/3000ms (Java/Other) Memory Limit : 65535/32768K (Java/ ...
- [2012山东省第三届ACM大学生程序设计竞赛]——n a^o7 !
n a^o7 ! 题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2413 Time Lim ...
- angry_birds_again_and_again(2014年山东省第五届ACM大学生程序设计竞赛A题)
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2877 题目描述 The problems ca ...
随机推荐
- h5 摄像头处理 在线视频
http://www.360doc.com/content/08/0812/03/72059_1533104.shtml http://html5online.com.cn/articles/2012 ...
- eclipse项目自动发布到tomcat目录,缺文件。
eclipse项目自动发布到tomcat目录,缺文件. 解决方案: 项目--Properties-->Deployment Assembly-->Add--> Folder Add- ...
- ajax访问服务器返回json格式
使用ajax访问服务器返回多条数据,比如返回一个表中的所有数据,页面该如何处理呢?如何获取数据呢?一直不会用ajax返回json格式,今天研究了下,分享给大家~ 首先需要引用服务,点击项目右键,添加引 ...
- MySql密码忘记解决方法
1.先杀掉mysqld-nt.exe 进程,有很多种方法,最简单是在CMD里输入net stop mysql 2.CMD路径切换到MySQL的安装目录下的bin里 输入mysqld-nt.exe - ...
- Session过期、失效时间
Session一直是我们做web项目经常使用的,以前没太注意,这次又细致的看了下! 1.session其实就是一个Map,键=值对,通过session.getAttribute("name& ...
- SegmentControl的多选项实现(标题栏)
NSArray *titleArr = @[STR(@"全部"), STR(@"未使用"), STR(@"已赠送"), STR(@" ...
- myeclipse10的激活
myeclipse 提醒了我好几天要激活,今天操作了下,出现的问题分享一下. 在激活工具里面没有找到cracker.jar,按照指导双击run.bat,但是打开之后闪一下就自动关闭了,不得其解.然后搜 ...
- Object.create()方法的低版本兼容问题
Object.prototype.create=(function(){ if(Object.prototype.create){return Object.prototype.create}else ...
- HR开发 操作信息类型数据
1.通过函数操作. . DATA: ZRETURN TYPE BAPIRETURN1, ZPAKEY TYPE BAPIPAKEY. GET PERNR. LOOP AT P0001 WHERE .. ...
- Excel列名 字母和数字的转换
Excel的列名是由于字母组成的. A-Z 分别代表1-26 AA 是27 AB是28 以此类推. 以下是这种编码的转换方法,如果遇到需要用纯字母编号来表示数字的时候可以用到. /** * 类似EX ...