QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#198517#669. HashkjhhjkiCompile Error//C++20977b2023-10-03 14:31:392023-10-03 14:33:02

Judging History

This is the latest submission verdict.

  • [2023-10-03 14:33:02]
  • Judged
  • [2023-10-03 14:31:39]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
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));
    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';
    }
}

详细

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:1:
/usr/include/stdlib.h:401:17: note: old declaration ‘long int random()’
  401 | extern long int random (void) __THROW;
      |                 ^~~~~~