SDUT2608(Alice and Bob)
来源:互联网 发布:淘宝制作主图ps视频 编辑:程序博客网 时间:2024/05/18 13:43
题目描述
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?
输入
The first line of the input is a number T, which means the number of the test cases.
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
输出
For each question of each test case, please output the answer module 2012.
示例输入
122 1234
示例输出
20
提示
The expansion of the (2*x^(2^0) + 1) * (1*x^(2^1) + 1) is 1 + 2*x^1 + 1*x^2 + 2*x^3
来源
2013年山东省第四届ACM大学生程序设计竞赛
#include<stdio.h>#include<string.h>int main(){ long long p,tem,tt; int n,q,t,i,k,a[55],sum; scanf("%d",&t); while(t--) { scanf("%d",&n); memset(a,0,sizeof(a)); for(i=0;i<n;i++) scanf("%d",&a[i]); scanf("%d",&q); while(q--) { scanf("%lld",&p); sum=1; while(p>0) { k=0;tem=p;tt=1; while(tem) { if(tem>1)tt*=2; k++;tem/=2; } sum=(sum*a[k-1])%2012; p-=tt; } printf("%d\n",sum%2012); } }}
- SDUT2608(Alice and Bob)
- Alice and Bob(长春)
- Alice and Bob(博弈)
- ZOJ 3666 Alice and Bob(博弈)
- HDU 4268 Alice and Bob(贪心)
- ACdream群赛1112(Alice and Bob)
- HDU 4268 Alice and Bob(贪心)
- HDU 4268 Alice and Bob (贪心)
- hdu 4268 Alice and Bob(multiset)
- HDU 5054 Alice and Bob(数学)
- XTU 1209 Alice and Bob (博弈)
- HDU 4268 Alice and Bob(贪心)
- hdu4268 Alice and Bob(贪心)
- hdu 5054 Alice and Bob(水题)
- hdu 4268 Alice and Bob(贪心)
- Alice and Bob
- 2683. Alice and Bob
- 1798. Alice and Bob
- 花样Android ProgressBar 史上最强大讲解
- jQuery 方法 属性
- 16种oracle查询日期语句
- OpenCV 最小二乘拟合方法求取直线倾角
- 【数据库系列】之存储过程与触发器
- SDUT2608(Alice and Bob)
- 程序员必知的8大排序
- 3DES加密算法
- WinForms 控件
- 南阳OJ-214-最长子序列-二分查找给力啊哈哈
- [POJ 2104]K-th Number (不带修改的区间k大,函数式线段树)
- 一个web项目web.xml的配置中<context-param>配置作用
- 题目1190:大整数排序
- 关于AES加密(下)