QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501076#5158. Interview QuestionxixuCompile Error//C++141.2kb2024-08-02 13:38:452024-08-02 13:38:45

Judging History

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

  • [2024-08-02 13:38:45]
  • 评测
  • [2024-08-02 13:38:45]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int , int> PII;


const int N = 1e5 + 10;


vector<int> a , b;

void solve()
{
    int c , d;
    cin >> c >> d;

    for(int i = c; i <= d; i ++)
    {
        string s;
        cin >> s;
        if(s == "Fizz")
        {
            a.push_back(i);
        }
        else if(s == "Buzz")
        {
            b.push_back(i);
        }
        else if(s == "FizzBuzz")
        {
            a.push_back(i);
            b.push_back(i);
        }
    }


    int ans;
    if(a.size())
    {
        ans = a[0];
    }
    else
    {
        ans = d + 1;
    }
    
    for(int i = 0; i < a.size(); i ++)
    {
        ans = gcd(ans , a[i]);
    }

    cout << ans << ' ';

    if(b.size()) ans = b[0];
    else ans = d + 1;
    
    for(int i = 0; i < b.size(); i ++)
    {
        ans = gcd(ans , b[i]);
    }

    cout << ans << '\n';





}



signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int t = 1;
    // cin >> t;
    while(t --)
    {
        solve();
    }

    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:50:15: error: ‘gcd’ was not declared in this scope
   50 |         ans = gcd(ans , a[i]);
      |               ^~~
answer.code:60:15: error: ‘gcd’ was not declared in this scope
   60 |         ans = gcd(ans , b[i]);
      |               ^~~