QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#198366 | #669. Hash | kjhhjki | WA | 1ms | 3516kb | C++20 | 1.6kb | 2023-10-03 13:24:16 | 2023-10-03 13:24:17 |
Judging History
answer
#include <bits/stdc++.h>
#define read() ({int x,c,f=1;while((c=getchar())<48||57<c)if(c=='-')f=-1;for(x=c^48;47<(c=getchar())&&c<58;)x=x*10+(c^48);x*f; })
using namespace std;
long long a, b;
string trans(long long hash)
{
if (hash < a)
return string(1, char(hash - 1 + 'a'));
return trans(hash / a) + char(hash % a - 1 + 'a');
}
bool reg(const string &s)
{
for (char c : s)
if (!isalpha(c))
return false;
return true;
}
long long hash(const string &s)
{
long long h = 0;
for (char c : s)
h = (h * a + c - 'a' + 1);
return h;
}
int main()
{
a = read(), b = read();
if (a == 26)
{
string s;
for (int i = 25; i--;)
s += "ba";
cout << s << '\n';
for (int i = 0; i < 50; i += 2)
{
string t(s);
t[i]--;
t[i + 1] = 'z';
cout << t << '\n';
}
int cnt = 26;
for (int i = 0; i < 50; i += 2)
for (int j = i + 2; j < 50; j += 2)
{
string t(s);
t[i]--;
t[i + 1] = 'z';
t[j]--;
t[j + 1] = 'z';
cout << t << '\n';
if (++cnt == 100)
return 0;
}
}
string s;
for (long long i = 0, cnt = 0; cnt < 100; ++i)
{
while (!reg(s = trans(1 + i * b)))
i++;
cnt++;
cout << s << '\n';
//printf("hash = %lld\n", ::hash(s));
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3516kb
input:
215465827 841597626
output:
a kN FM iN DM Sh gN BM Qh eN Oh cN ri Mh aN pi Kh ni Ih li Gh RU ji Eh PU hi Ch NU fi qV LU di oV JU mV HU kV FU Up iV DU OB Sp gV vq BU MB Qp eV pC tq KB Op cV nC rq IB Mp aV lC pq GB Kp jC nq EB Ip hC lq CB Gp fC jq AB Ep dC hq bC fq Wx QJ Ux xy OJ Sx rK vy MJ Qx pK ty KJ Ox nK ry IJ Mx lK py GJ
result:
wrong answer contains invalid char : kN