結果

問題 No.8015 アンチローリングハッシュ
ユーザー a01sa01to
提出日時 2025-07-24 00:46:42
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 764 bytes
コンパイル時間 3,200 ms
コンパイル使用メモリ 283,760 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-07-24 00:46:47
合計ジャッジ時間 4,586 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  ll x, y;
  cin >> x >> y;
  map<ull, string> mp;
  for (int a = 'a'; a <= 'z'; ++a) {
    for (int b = 'a'; b <= 'z'; ++b) {
      for (int c = 'a'; c <= 'z'; ++c) {
        for (int d = 'a'; d <= 'z'; ++d) {
          string s = { char(a), char(b), char(c), char(d) };
          ull hash = (a * x * x * x + b * x * x + c * x + d) % y;
          if (mp.contains(hash)) {
            cout << s << '\n'
                 << mp[hash] << '\n';
            return 0;
          }
          mp[hash] = s;
        }
      }
    }
  }
  assert(false);
  return 0;
}
0