結果

問題 No.3015 アンチローリングハッシュ
ユーザー Ryuhei MoriRyuhei Mori
提出日時 2019-09-26 19:20:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 880 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 58,236 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 15:39:47
合計ジャッジ時間 1,374 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <map>
#include <utility>

int a, b;

/*
aaaa
ABCD

(A-a) a^3 + (B-a) a^2 + (C-a) a + (D-a) = 0 mod b
*/

int main(){
  std::map<int, std::pair<int, int> > m;
  scanf("%d%d",&a,&b);

  for(int i=0;i<26;i++){
    for(int j=0;j<26;j++){
      int z = (i * a + j) % b;
      if(m.count(z)){
        std::pair<int, int> p = m[z];
        printf("%c%c\n",'a'+p.first,'a'+p.second);
        printf("%c%c\n",'a'+i,'a'+j);
        return 0;
      }
      m.insert({z, std::pair<int, int>(i, j)});
    }
  }
  int a2 = (long long) a*a%b;
  a2 = a2 == 0 ? 0 : b - a2;
  for(const auto& [val, p]: m){
    if(val == 0) continue;
    int z = (long long) val * a2 % b;
    if(m.count(z)){
      std::pair<int, int> q = m[z];
      puts("aaaa");
      printf("%c%c%c%c\n", 'a'+p.first, 'a'+p.second, 'a'+q.first, 'a'+q.second);
      return 0;
    }
  }

  return 0;
}
0