結果
| 問題 |
No.8015 アンチローリングハッシュ
|
| ユーザー |
|
| 提出日時 | 2019-09-26 19:05:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 920 bytes |
| コンパイル時間 | 489 ms |
| コンパイル使用メモリ | 54,016 KB |
| 最終ジャッジ日時 | 2025-01-07 19:11:51 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d%d",&a,&b);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#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(int i=0;i<26;i++){
for(int j=0;j<26;j++){
if((i|j) == 0) continue;
int z = (long long) (i * a + j) * a2 % b;
if(m.count(z)){
std::pair<int, int> p = m[z];
puts("aaaa");
printf("%c%c%c%c\n", 'a'+i, 'a'+j, 'a'+p.first, 'a'+p.second);
return 0;
}
}
}
return 0;
}