QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#96311#5158. Interview QuestionZuqa#WA 2ms3504kbC++202.1kb2023-04-13 19:15:112023-04-13 19:15:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-13 19:15:15]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3504kb
  • [2023-04-13 19:15:11]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define el '\n'
#define FIO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
typedef unsigned long long ull;

template<typename T, typename X>
using hashTable = gp_hash_table<T, X>;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937_64 for long long
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());

void doWork()
{
    int c, d;
    cin >> c >> d;
    int a = 5e5, b = 5e6;
    int ga = 0, gb = 0;
    vector<int> fizz, buzz;
    for(int i = c; i <= d; ++i)
    {
        string s;
        cin >> s;
        int cnt = 0;
        if(s.find("Fizz") != -1)
            ga = __gcd(ga, i);
        else fizz.push_back(i);
        if(s.find("Buzz") != -1)
            gb = __gcd(gb, i);
        else buzz.push_back(i);
    }
    for(int i = 1; i <= max(ga, gb); ++i)
    {
        if(ga % i == 0 && (a > 1e5))
        {
            int f = 1;
            for(int j = 0; j < fizz.size(); ++j)
            {
                if(fizz[j] % i == 0)
                    f = 0;
            }
            if(f)
            {
                a = i;
                // break;
            }

        }
        if(gb % i == 0 && (b > 1e5))
        {
            int f = 1;
            for(int j = 0; j < buzz.size(); ++j)
            {
                if(buzz[j] % i == 0)
                    f = 0;
            }
            if(f)
            {
                b = i;
                //break;
            }

        }
    }
    cout << a << " " << b << endl;
}

signed main()
{
    FIO
    int T = 1;
//    cin >> T;
    for(int i = 1; i <= T; i++)
        doWork();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3412kb

input:

7 11
7 8 Fizz Buzz 11

output:

3 5

result:

ok 

Test #2:

score: 0
Accepted
time: 2ms
memory: 3456kb

input:

49999 50002
49999 FizzBuzz 50001 Fizz

output:

2 4

result:

ok 

Test #3:

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

input:

8 11
Buzz Buzz FizzBuzz Buzz

output:

5 1

result:

ok 

Test #4:

score: -100
Wrong Answer
time: 2ms
memory: 3504kb

input:

10 15
10 11 12 13 14 15

output:

500000 5000000

result:

wrong answer Integer parameter [name=b] equals to 5000000, violates the range [1, 1000000]