• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

2013 Asia Nanjing Regional Contest I

Wall Painting

Time Limit: 10000/5000 MS (Java/Others)   

 Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 411    Accepted Submission(s): 121

Problem Description
Ms.Fang loves painting very much. She paints GFW(Great Funny Wall) every day. Every day before painting, she produces a wonderful color of pigments by mixing water and some bags of pigments. On the K-th day, she will select K specific bags of pigments and mix them to get a color of pigments which she will use that day. When she mixes a bag of pigments with color A and a bag of pigments with color B, she will get pigments with color A xor B. When she mixes two bags of pigments with the same color, she will get color zero for some strange reasons. Now, her husband Mr.Fang has no idea about which K bags of pigments Ms.Fang will select on the K-th day. He wonders the sum of the colors Ms.Fang will get with different plans. For example, assume n = 3, K = 2 and three bags of pigments with color 2, 1, 2. She can get color 3, 3, 0 with 3 different plans. In this instance, the answer Mr.Fang wants to get on the second day is 3 + 3 + 0 = 6. Mr.Fang is so busy that he doesn’t want to spend too much time on it. Can you help him? You should tell Mr.Fang the answer from the first day to the n-th day.
 
Input
There are several test cases, please process till EOF. For each test case, the first line contains a single integer N(1 <= N <= 103).The second line contains N integers. The i-th integer represents the color of the pigments in the i-th bag.
 
Output
For each test case, output N integers in a line representing the answers(mod 106 +3) from the first day to the n-th day.
 
Sample Input
4
1 2 10 1
 
Sample Output
14 36 30 8
 
Source
2013ACM/ICPC亚洲区南京站现场赛——题目重现
 
Recommend
liuyiding
 
 1 #include <cstdio>
 2 #include <vector>
 3 #include <cmath>
 4 #include <queue>
 5 #include <cstring>
 6 #include <iostream>
 7 #include <algorithm>
 8 using namespace std;
 9 #define INF 0x7fffffff
10 #define mod 1000003
11 #define ll long long
12 #define maxn 1005
13 #define pi acos(-1.0)
14 int n, m, k, d, x, y;
15 int a[maxn],p[maxn];
16 int c[maxn][maxn];
17 void init(){
18     p[1] = 1;
19     for (int i = 2; i < 32; i++)p[i] = (p[i - 1]<<1)%mod;
20     c[0][0] = 1; c[1][0] = c[1][1] = 1;
21     for (int i = 2; i < maxn; i++){
22         c[i][0] = 1;
23         for (int j = 1; j <= i; j++){
24             c[i][j] = (c[i-1][j] +c[i-1][j-1])%mod;
25         }
26     }
27 }
28 int main(){
29     init();
30     while (~scanf("%d", &n)){
31         memset(a, 0, sizeof a);
32         for (int i = 1; i <= n; i++){
33             scanf("%d", &x);
34             for (int j = 1; x; j++,x>>=1)
35                 a[j]+=x&1;
36         }
37         for (int i = 1; i <= n; i++){
38             int ans = 0;
39             for (int j = 1; j < 32; j++){
40                 for (int k = 1; k <= a[j] && k <= i; k += 2){
41                     if (n - a[j] < i - k)continue;
42                     int tmp = ((ll)c[a[j]][k] * c[n - a[j]][i - k]) % mod;
43                     ans = (ans + (ll)tmp*p[j]%mod) % mod;
44                 }
45             }
46             printf(i == n ? "%d\n" : "%d ", ans);
47         }
48     }
49     return 0;
50 }
View Code
posted @ 2013-12-21 12:15  HaibaraAi  阅读(105)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3