日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SDUT2608(Alice and Bob)

發布時間:2025/3/21 编程问答 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SDUT2608(Alice and Bob) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目描述

? ? 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.

示例輸入

1 2 2 1 2 3 4

示例輸出

2 0

提示

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);}} }

?

《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的SDUT2608(Alice and Bob)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。