QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#198526#669. HashkjhhjkiTL 0ms0kbC++20985b2023-10-03 14:35:392023-10-03 14:35:40

Judging History

This is the latest submission verdict.

  • [2023-10-03 14:35:40]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 0kb
  • [2023-10-03 14:35:39]
  • 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';
    }
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

215465827 841597626

output:


result: