QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#201305#5158. Interview QuestionTeam_name#WA 0ms3832kbC++201.1kb2023-10-05 13:37:572023-10-05 13:37:58

Judging History

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

  • [2023-10-05 13:37:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3832kb
  • [2023-10-05 13:37:57]
  • 提交

answer

#include <iostream>
#include <numeric>
#include <string>
constexpr int N = 1E5, MAX = 1E6;
bool F[N + 1], B[N + 1];
int main()
{
	std::ios_base::sync_with_stdio(false), std::cin.tie(nullptr);
	int c, d; std::cin >> c >> d;
	int a = 0, b = 0, ab = 0;
	for (int i = c; i <= d; ++i)
	{
		std::string s; std::cin >> s;
		if (s == "Fizz")
			F[i] = true, a = std::gcd(a, i);
		else if (s == "Buzz")
			B[i] = true, b = std::gcd(b, i);
		else if (s == "FizzBuzz")
			F[i] = B[i] = true, ab = std::gcd(ab, i);
	}
	if (!ab)
	{
		std::cout << (a ? a : MAX) << " " << (b ? b : MAX) << "\n";
		return 0;
	}
	auto check = [c, d](int a, int b) {
		for (int i = c; i <= d; ++i)
			if (!(i % a) != F[i])
				return false;
		for (int i = c; i <= d; ++i)
			if (!(i % b) != B[i])
				return false;
		return true;
	};
	for (int i = 1; i * i <= ab; ++i)
		if (!(ab % i))
		{
			int j = ab / i;
			if (check(i, j))
			{
				std::cout << i << " " << j << "\n";
				return 0;
			}
			if (check(j, i))
			{
				std::cout << j << " " << i << "\n";
				return 0;
			}
		}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

7 11
7 8 Fizz Buzz 11

output:

9 10

result:

ok 

Test #2:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

49999 50002
49999 FizzBuzz 50001 Fizz

output:

2 25000

result:

ok 

Test #3:

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

input:

8 11
Buzz Buzz FizzBuzz Buzz

output:

10 1

result:

ok 

Test #4:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

10 15
10 11 12 13 14 15

output:

1000000 1000000

result:

ok 

Test #5:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

17 17
17

output:

1000000 1000000

result:

ok 

Test #6:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

13 13
Fizz

output:

13 1000000

result:

ok 

Test #7:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

20 20
Buzz

output:

1000000 20

result:

ok 

Test #8:

score: 0
Accepted
time: 0ms
memory: 3492kb

input:

30 30
FizzBuzz

output:

1 30

result:

ok 

Test #9:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

9 10
Buzz FizzBuzz

output:

10 1

result:

ok 

Test #10:

score: -100
Wrong Answer
time: 0ms
memory: 3616kb

input:

2 6
2 3 4 5 FizzBuzz

output:


result:

wrong output format Unexpected end of file - int32 expected