joj 2653 不同的数 从2*n中找出不相同的两个数

2653: 不同的数


ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE
3s65536K38778Standard

原来有n对数字,每对两个数字都相同。现在其中某对数字中的一个发生了变化。并且所有数字被打乱了顺序。求这一对数字变化后是多少。要求先输出小的。再输出大的。

Input

多组输入,每组如下:第一行一个数字n, n <= 1000000 以下2n行,每行一个数字,打乱顺序后的所有数字。 n=0表示输入结束。

Output

每组一行。两个数字。表示发生变化后的一组。

Sample Input

3
1
2
3
2
2
3
0

Sample Output

1 2

 

 //

 

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int sum0[33],sum1[33];
int main()
{
    while(scanf("%d",&n)==1&&n)
    {
        n<<=1;
        memset(sum0,0,sizeof(sum0));
        memset(sum1,0,sizeof(sum1));
        for(int i=0;i<n;i++)
        {
            int t;scanf("%d",&t);//t>0
            for(int j=0;j<32;j++)
            {
                if(t&(1<<j)) sum1[j]^=t;
                else sum0[j]^=t;
            }
        }
        for(int i=0;i<32;i++)
        {
            if(sum0[i]&&sum1[i])
            {
                int rmax=max(sum0[i],sum1[i]);
                int rmin=min(sum0[i],sum1[i]);
                printf("%d %d\n",rmin,rmax);
                break;
            }
        }
    }
    return 0;
}

### Python Join Function Usage and Examples In Python, the `str.join()` method is a string operation that returns a string in which the elements of sequence have been joined by a specified separator. The syntax for this function is as follows: ```python 'connector'.join(iterable) ``` The parameter `iterable` must be a series of strings; otherwise, a `TypeError` will occur unless all items can be converted into strings implicitly. For instance, joining words with spaces or creating comma-separated values are common use cases: ```python words = ["hello", "world"] print(' '.join(words)) # hello world csv_elements = ['apple', 'banana', 'cherry'] print(','.join(csv_elements)) # apple,banana,cherry ``` When working with file paths where slashes need to separate directory names, one might also utilize join: ```python path_parts = ['folder1', 'subfolder2', 'file.txt'] print('/'.join(path_parts)) # folder1/subfolder2/file.txt ``` To concatenate multiple lines within a single string while ensuring each part appears on its own line, newline characters serve well as separators: ```python lines = ["First line", "Second line", "Third line"] multi_line_string = '\n'.join(lines) print(multi_line_string) # First line # Second line # Third line ``` It's important to note that only string types should reside inside the iterable passed to `.join()`. If integers exist among these elements, they require conversion first using methods like list comprehension combined with str(): ```python numbers = [1, 2, 3] string_numbers = '-'.join([str(num) for num in numbers]) print(string_numbers) # 1-2-3 ``` --related questions-- 1. How does the performance of `str.join()` compare against other concatenation techniques? 2. What exceptions may arise when improperly utilizing `str.join()`? 3. Can you provide scenarios beyond those mentioned here where `str.join()` proves particularly useful? 4. Is there any difference between `''.join(list)` versus directly adding strings together via `+` operator concerning memory allocation?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值