Skip to main content
  1. Posts/

bc #77 div 2 1001 ||hdu 5650 so easy (傻逼题)

·1 min
Note: This article is available in Chinese only. 本文暂无英文版本。 View original

题目链接 題意:已知一个包含 nn 个元素的正整数集合 SS,设 f(S)f(S) 为集合 SS 中所有元素的异或(XOR)的结果。 如:S={1,2,3}, 则 f(S) = 0f(S)=0。

给出集合 SS,你需要计算 将所有 f(s)进行异或后的值, s⊆S.

思路:当集合中元素大于1个的时候,每个元素对都会出现偶数次,对答案的贡献为0.

当集合中只有一个元素的时候,设为x,对答案的贡献为x.

 1/* ***********************************************
 2Author :111qqz
 3Created Time :2016年03月26日 星期六 18时52分14秒
 4File Name :code/bc/#77/1002.cpp
 5************************************************ */
 6
 7#include <cstdio>
 8#include <cstring>
 9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33const int N=1005;
34int n;
35int a[N];
36int main()
37{
38	#ifndef  ONLINE_JUDGE
39	freopen("code/in.txt","r",stdin);
40  #endif
41
42	int T;
43	cin>>T;
44	while (T--)
45	{
46	    scanf("%d",&n);
47
48	    for ( int i = 0 ; i < n ; i++) scanf("%d",&a[i]);
49
50	    if (n==1)
51	    {
52		printf("%d\n",a[0]);
53	    }
54	    else
55	    printf("0\n");
56	}
57
58  #ifndef ONLINE_JUDGE
59  fclose(stdin);
60  #endif
61    return 0;
62}

Related

uva 152 Tree's a Crowd

·2 mins
题意:题意:给你一组三维空间中的点,每个点到其它点都有个距离,其中有个最小距离,如果这个最小距离小于10,就将对应的距离的点个数加1,最后输出距离为0,1,2…8,9的点的个数。(from 百度) 老实说,上面这题意也讲的不明不白,其实这题非常水,就是对每个点进行判断,找出和其他点最短的距离,在下标为该距离的数组上+1,最后输出数组下标0-9的数。 trick:其实最小距离大于9的就不用存放了,只要开个大小10的数组。(不会概括。。。抄的别人的)

codeforces #322 div 2 A. Vasya the Hipster(纱布题)

·1 min
A. Vasya the Hipster time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.

uva 489

·2 mins
In ``Hangman Judge,’’ you are to write a program that judges a series of Hangman games. For each game, the answer to the puzzle is given as well as the guesses. Rules are the same as the classic game of hangman, and are given as follows:

codeforces #120 div 2 (Virtual Participation)

·2 mins
比赛链接 两题QAQ A:7分钟1A 有n个大人m个小孩乘公交车,票价每人一元,一个大人最多免费带一个小孩,没有大人陪同的小孩不能乘车。 问是否有解,如果有解输出所有乘客付的钱的可能的最小值和可能的最大值。