2024CCPC 网络选拔赛 解题报告

The first line of input file is an integer T.

Then the T lines contains 2 positive integers, A and B, (1≤A,B<232)

Output


For each test case,you should output the answer and a line for each answer.

Sample Input


1 3 5

Sample Output


1

题意分析


找出最小的值c使(ac)&(bc)最大。 (位运算的水题,签到)

#include

#include

#include

#include <math.h>

#include <string.h>

#include

#include

using namespace std;

#define ll long long

#define fo(i, a, b) for (int i = a; i < b; i++)

#define foo(i, a, b) for (int i = a; i > b; i–)

#define mst(a, b) memset(a, b, sizeof(a))

const int maxn = 1e5+10;

int main()

{

//freopen(“in.txt”, “r”, stdin);

ios::sync_with_stdio(false);

ll a, b;

int t;

cin >> t;

while (t–)

{

cin >> a >> b;

if ((a & b) == 0)

cout << min(a, b);

else

cout << (a & b);

cout << endl;

}

return 0;

}

1006 Shuffle Card(HDU6707)

==========================

Problem Description

A deck of card consists of n cards. Each card is different, numbered from 1 to n. At first, the cards were ordered from 1 to n. We complete the shuffle process in the following way, In each operation, we will draw a card and put it in the position of the first card, and repeat this operation for m times.

Please output the order of cards after m operations.

Input

The first line of input contains two positive integers n and m.(1<=n,m<=105)

The second line of the input file has n Numbers, a sequence of 1 through n.

Next there are m rows, each of which has a positive integer si, representing the card number extracted by the i-th operation.

Output

Please output the order of cards after m operations. (There should be one space after each number.)

Sample Input

5 3

1 2 3 4 5

3

4

3

Sample Output

3 4 1 2 5

题意分析:


最开始给出一个排列,然后m次操作,把a移动到最前面,求最后的排列(stl+简单模拟。签到)

解题思路:


用map进行查重模拟一遍,不论某个数字改变多少次,怎么移动。从最后一步往前推。最后一步移动的肯定是在最前面。

然后依次在后面,往结果里存,用map检查该数字是否已经存入结果。

(这题因为我数组开小了,把1e5当做1w了,超时了好几次。我自己背锅。在时间允许的情况下,建议开动态的。避免我这样的问题,超时的原因吃好几次罚时才出来。)

#include

#include

#include

#include <math.h>

#include <string.h>

#include

#include

using namespace std;

#define ll long long

#define fo(i, a, b) for (int i = a; i < b; i++)

#define foo(i, a, b) for (int i = a; i > b; i–)

#define mst(a, b) memset(a, b, sizeof(a))

const int maxn = 100500;

int main()

{

// freopen(“in.txt”, “r”, stdin);

ios::sync_with_stdio(false);

map<int, int> a;

int q[maxn];

int qq[maxn];

int s[maxn];

int n, m;

while (cin >> n >> m)

{

map<int, int> a;

fo(i, 0, n)

{

cin >> q[i];

a[q[i]] = 0;

}

fo(i, 0, m)

{

cin >> qq[i];

}

foo(i, m - 1, -1)

{

if (a[qq[i]] != 1)

{

cout << qq[i] << ’ ';

a[qq[i]] = 1;

}

}

fo(i, 0, n)

{

if (a[q[i]] == 0)

{

cout << q[i] << ’ ';

a[q[i]] = 1;

}

}

mst(q, 0);

mst(qq, 0);

mst(s, 0);

}

}

1007 Windows Of CCPC(HDU6708)


Problem Description


In recent years, CCPC has developed rapidly and gained a large number of competitors .One contestant designed a design called CCPC Windows .The 1-st order CCPC window is shown in the figure:

And the 2-nd order CCPC window is shown in the figure:We can easily find that the window of CCPC of order k is generated by taking the window of CCPC of order k−1 as C of order k, and the result of inverting C/P in the window of CCPC of order k−1 as P of order k.

And now I have an order k ,please output k-order CCPC Windows , The CCPC window of order k is a 2k∗2k matrix.

input


The input file contains T test samples.(1<=T<=10)

The first line of input file is an integer T.

Then the T lines contains a positive integers k , (1≤k≤10)

Output


For each test case,you should output the answer .

Sample Input


3

1

2

3

Sample Output


CC

PC

CCCC

PCPC

PPCC

CPPC

CCCCCCCC

PCPCPCPC

PPCCPPCC

CPPCCPPC

PPPPCCCC

CPCPPCPC

CCPPPPCC

PCCPCPPC

题意分析:


规则 :最开始是4个字符左下角那个和其余3个不一样,用最初的可以拼成第2个,把第2个分成4部分,左下角和第一个相反,也就是P变为C,C变为P,其余相同。

思路:


按照上面的规则,看k的数据范围不是很大,就用打表的方式,因为每一个k的表都是建立在k-1的情况下。(题目虽然不难,但是理清怎么打好这个表,不容易,心累)

#include

#include

#include

#include <math.h>

#include <string.h>

using namespace std;

#define ll long long

#define fo(i, a, b) for (int i = a; i < b; i++)

#define foo(i, a, b) for (int i = a; i > b; i++)

#define mst(a, b) memset(a, b, sizeof(a))

const int maxn = 1050;

char ch[maxn][maxn];

int main()

{

//freopen(“in.txt”, “r”, stdin);

ios::sync_with_stdio(false);

mst(ch,0);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值