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 ...
随机推荐
- jquery实现淡入淡出
fade方法包括四个: (1)fadeIn(speed,callback):淡入的方法,speed代表淡入的速度,可以是slow,fast,毫秒,不填等 例如: $(document).ready(f ...
- 关于localstorage的几个测试
1.如果在同一主域名下,localstorage能访问吗? 测试: 在www\index.php 中写入 localstorage 在www\wex5fortp\ui 目录下能否读到?? 结论:可以得 ...
- java io流之BufferReader&BufferedWriter
BufferedReader 由Reader类扩展而来,提供通用的缓冲方式文本读取,而且提供了很实用的readLine,读取一个文本行,从字符输入流中读取文本,缓冲各个字符,从而提供字符.数组和行的高 ...
- 第一章 删掉centos原有的openjdk并安装sun jdk
一.卸载原有openjdk rpm -qa | grep java 之后,将展示出来的全部卸载掉,我这里是5个 rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111 ...
- june 14
Thank you for your applying for employment with our company. Your application is now being processed ...
- Linux cp命令使用说明
Linux cp命令使用说明 --功能说明:复制目录或文件 --命令格式:cp [参数] <文件或目录> <文件或目录> --常用参数: -R 复制目录 -i 覆盖文件之 ...
- SAP 采购订单行项目中科目分配被隐藏,发现行项目设置中显示字段长度为0
1.sm30 维护 视图 TCVIEW 修改对应字段的显示长度
- Coursera Machine Learning : Regression 评估性能
评估性能 评估损失 1.Training Error 首先要通过数据来训练模型,选取数据中的一部分作为训练数据. 损失函数可以使用绝对值误差或者平方误差等方法来计算,这里使用平方误差的方法,即: (y ...
- python autopep8
安装 使用pip install autopep8或easy_install 都可以. 使用 autopep8 -i -a 要检查的py文件路径 更多参数使用可以参考:https://github.c ...
- linux python升级和ipython的安装
==CentOS 6.X 自带的python版本是 2.6 , 由于工作需要,很多时候需要2.7版本.所以需要进行版本升级.由于一些系统工具和服务是对 Python 有依赖的,所以升级 Python ...