# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97026 | Kastanda | Question (Grader is different from the original contest) (CEOI14_question_grader) | C++11 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// And I was like ooo-eee-ooo
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
inline int Hash(int X, int Mod = 1997)
{
vector < int > A;
int M = X;
while (M)
A.pb(M % 3 + 19), M /= 3;
M = X;
while (M)
A.pb((M % 2 + 3) * 2 + 11), M /= 2;
int hsh = 0;
for (int a : A)
hsh = (hsh + a) * 1223 % Mod;
return hsh;
}
int main()
{
int N, T, X, Y;
scanf("%d%d", &N, &T);
for (; T; T --)
{
scanf("%d%d", &X, &Y);
printf("%d\n", Hash(X) % 12 + 1);
}
return 0;
}
// White tiger's like ooo-aaa--oooo
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
inline int Hash(int X, int Mod = 1997)
{
vector < int > A;
int M = X;
while (M)
A.pb(M % 3 + 19), M /= 3;
M = X;
while (M)
A.pb((M % 2 + 3) * 2 + 11), M /= 2;
int hsh = 0;
for (int a : A)
hsh = (hsh + a) * 1223 % Mod;
return hsh;
}
int main()
{
int N, T, Q, H;
scanf("%d%d", &N, &T);
for (; T; T --)
{
scanf("%d%d", &Q, &H);
if (Hash(Q) % 12 + 1 == H)
printf("yes\n");
else
printf("no\n");
}
return 0;
}