QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#817173#7115. Can You Guess My Sequence?yellow_oneAC ✓0ms3836kbC++14814b2024-12-16 20:43:042024-12-16 20:43:04

Judging History

你现在查看的是最新测评结果

  • [2024-12-16 20:43:04]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3836kb
  • [2024-12-16 20:43:04]
  • 提交

answer

#include<iostream>
#include<string>
using namespace std;
int main()
{
	string name;
	cin >> name;
	if (name == "Alice")
	{
		int n, num;
		char ans[20];
		for (int i = 0; i < 20; i++) ans[i] = '0';
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			cin >> num;
			ans[num] = '1';
		}
		int oh = 0, mid = 1, che = 1;
		for (int i = 0; i < 20; i++)
		{
			mid = che *(ans[i] - '0');
			oh += mid;
			che *= 2;
		}
		cout << oh << endl;
	}
	else
	{
		int num;
		cin >> num;
		int all = 0, a[20], mid = num;
		for (int i = 0; mid>0; i++)
		{
			a[i] = mid % 2;
			if (a[i] == 1) all++;
			mid /= 2;
		}
		cout << all << endl;
		int k = 0;
		for (int i = 0; i < all; i++)
		{
			while (k<20&&a[k] == 0) k++;
			cout << k << ' ';
			k++;
		}
		cout << endl;
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

First Run Input

Alice
6
2 3 5 8 10 15

First Run Output

34092

Second Run Input

Bob
34092

Second Run Output

6
2 3 5 8 10 15 

result:

ok correct

Test #2:

score: 100
Accepted
time: 0ms
memory: 3600kb

First Run Input

Alice
20
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

First Run Output

1048575

Second Run Input

Bob
1048575

Second Run Output

20
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 

result:

ok correct

Test #3:

score: 100
Accepted
time: 0ms
memory: 3608kb

First Run Input

Alice
1
0

First Run Output

1

Second Run Input

Bob
1

Second Run Output

1
0 

result:

ok correct

Test #4:

score: 100
Accepted
time: 0ms
memory: 3544kb

First Run Input

Alice
2
0 15

First Run Output

32769

Second Run Input

Bob
32769

Second Run Output

2
0 15 

result:

ok correct

Test #5:

score: 100
Accepted
time: 0ms
memory: 3540kb

First Run Input

Alice
10
1 3 5 7 9 11 12 14 15 16

First Run Output

121514

Second Run Input

Bob
121514

Second Run Output

10
1 3 5 7 9 11 12 14 15 16 

result:

ok correct

Test #6:

score: 100
Accepted
time: 0ms
memory: 3576kb

First Run Input

Alice
3
16 17 18

First Run Output

458752

Second Run Input

Bob
458752

Second Run Output

3
16 17 18 

result:

ok correct

Test #7:

score: 100
Accepted
time: 0ms
memory: 3836kb

First Run Input

Alice
18
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 19

First Run Output

655359

Second Run Input

Bob
655359

Second Run Output

18
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 19 

result:

ok correct