第四届 Alice and Bob

Description

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 theexpansion of the Polynomial, Given an integer P, please tell the coefficient of the x^P.

Can you help Bob answer these questions?

Input

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

Output

For each question of each test case, please output the answer module 2012.

Sample Input

122 1234

Sample Output

20

Hint

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

我们展开多项式,以下面的为例


就此来看我们可以把P化成二进制形式然后对应的来求


#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
    int T;
    cin>>T;
    while(T--)
    {


        long long n,Q,p,A[55];
        memset(A,0,sizeof(A));
        cin>>n;
        for(int i=0;i<n;i++)
            cin>>A[i];
        cin>>Q;
        while(Q--)
        {
            cin>>p;
            int b[10005],c=0,ans=1;
            memset(b,0,sizeof(b));
            while(p!=0)
            {
                b[c++]=p%2;
                p/=2;
            }
            for(int i=c-1;i>=0;i--)
            {
                if(b[i]==1)
                {
                    ans=((ans%2012)*(A[i]%2012))%2012;
                }
            }
            cout<<ans%2012<<endl;
        }
    }
    return 0;
}


转载于:https://www.cnblogs.com/MisdomTianYa/p/6581748.html

### 第十六届蓝桥杯 EDA 相关试题及解答 关于第十六届蓝桥杯 EDA 的相关内容,虽然目前未提供具体题目和官方解析文档,但可以通过分析往届比赛的特点以及相似类型的题目来推测可能涉及的知识点和技术方向。 #### 蓝桥杯 EDA 题目特点 蓝桥杯 EDA 类别的题目通常围绕电子设计自动化(Electronic Design Automation, EDA)展开,重点考察参赛者对硬件电路设计的理解能力、软件工具的应用能力和编程实现的能力。常见的考点包括但不限于: - **逻辑门电路的设计与仿真** - **Verilog 或 VHDL 编程** - **数字信号处理基础** - **PCB 设计与布局优化** 以下是基于以往赛事经验整理的相关知识点及其应用: --- #### 示例题型及相关解答 ##### 1. 字符串排列问题 假设某道题目要求计算一行文字在不同字符宽度下的容纳数量,类似于引用中的描述[^3]。 **已知条件** - 如果每个字的宽为 `36` 像素,则一行可放下 `30` 个字。 - 计算当每个字宽为 `10` 像素时,一行能放下的字数。 **解决方法** 通过简单的比例关系得出结论:总像素长度固定不变的情况下,每种字体宽度对应的字数满足反比关系。 设总像素长度为 \( L \),则有: \[ L = 36 \times 30 = 1080 \] 因此,对于宽度为 `10` 像素的情况: \[ \text{字数} = \frac{1080}{10} = 108 \] 最终答案为:\( 108 \)[^3]。 --- ##### 2. 年份日期相关问题 此类问题是蓝桥杯的经典考题之一,常用于测试选手的时间戳转换、闰年判断等基本技能。例如引用中提到的暴力枚举法[^2]。 **示例代码 (Python)** 以下代码实现了从 `1901` 到 `2024` 年间所有天数的遍历,并统计特定条件下符合条件的日子总数。 ```python def is_leap_year(year): """判断是否为闰年""" return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) total_days = 0 for year in range(1901, 2025): # 枚举年份范围 days_in_year = 366 if is_leap_year(year) else 365 total_days += days_in_year print(total_days) ``` 上述程序的核心在于利用函数 `is_leap_year()` 来区分平年与闰年,并累加全年天数得到最终结果。 --- ##### 3. 数据格式化输出 数据格式化的技巧也经常出现在比赛中,尤其是在需要按照指定样式打印字符串或者数值的时候。比如引用中提及的一些常用格式说明符[^4]。 **表格展示样例** 下面展示了如何使用 Python 中的 f-string 和 format 方法完成复杂的数据排版任务。 ```python data = [("Alice", 25), ("Bob", 30), ("Charlie", 35)] # 使用 f-string 实现居中对齐 for name, age in data: print(f"{name:^10s}|{age:>5}") # 输出效果如下: # Alice | 25 # Bob | 30 # Charlie | 35 ``` 此片段演示了如何调整字段位置使其更加整齐美观。 --- #### 总结 尽管尚未获取到针对第十六届蓝桥杯 EDA 完整版本的具体资料,但从历年竞赛模式来看,主要集中在以下几个方面: - 数学运算与逻辑推理; - 时间序列分析; - 文本/图形渲染规则制定; - 硬件建模语言实践。 建议考生多关注类似主题的学习资源,并尝试独立解决问题以提升实战水平。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值