QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#198523#669. HashkjhhjkiCompile Error//C++14985b2023-10-03 14:35:122023-10-03 14:35:13

Judging History

This is the latest submission verdict.

  • [2023-10-03 14:35:13]
  • Judged
  • [2023-10-03 14:35:12]
  • Submitted

answer

#pragma GCC optimize(2)
#include <bits/stdc++.h>
typedef unsigned int ui;
 
ui a, b;
char s[10];
void random()
{
    s[0] = rand() % 26 + 'a';
    s[1] = rand() % 26 + 'a';
    s[2] = rand() % 26 + 'a';
    s[3] = rand() % 26 + 'a';
    s[4] = rand() % 26 + 'a';
    s[5] = rand() % 26 + 'a';
    s[6] = rand() % 26 + 'a';
    s[7] = '\0';
}
ui Hash(const char *s)
{
    ui h = 0;
    for (int i = 0; i < 7; ++i)
        h = (1ll * h * a + s[i] - 'a' + 1) % b;
    return h;
}

int main()
{
    srand(time(0));
    std::cin >> a >> b;
    random(); int cnt = 0;
    std::string str[2] = {s, ""};
    ui Hash1 = Hash(s), Hash2;
    for (;;)
    {
        random(); ++cnt;
        Hash2 = Hash(s);
        if (Hash2 == Hash1)
        { str[1] = s; break; }
    }
    for (int i = 0; i < 100; ++i)
    {
        std::string ans;
        for (int j = 0; j < 7; ++j)
            ans += str[i >> j & 1];
        std::cout << ans << '\n';
    }
}

Details

answer.code:7:6: error: ambiguating new declaration of ‘void random()’
    7 | void random()
      |      ^~~~~~
In file included from /usr/include/c++/11/bits/std_abs.h:38,
                 from /usr/include/c++/11/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:2:
/usr/include/stdlib.h:401:17: note: old declaration ‘long int random()’
  401 | extern long int random (void) __THROW;
      |                 ^~~~~~