Submission details
Task:Hacking hashes
Sender:aalto25l_005
Submission time:2025-11-19 17:59:21 +0200
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp:8:19: warning: overflow in conversion from 'double' to 'int' changes value from '9.9999999999999998e+66' to '2147483647' [-Woverflow]
    8 | const int MAXN1 = 1e67
      |                   ^~~~
input/code.cpp:9:1: error: expected ',' or ';' before 'const'
    9 | const int MAXN2 = 1e8;
      | ^~~~~
input/code.cpp:11:11: error: size of array 'f1' exceeds maximum object size '9223372036854775807'
   11 | string f1[MAXN1], f2[MAXN1];
      |           ^~~~~
input/code.cpp:11:22: error: size of array 'f2' exceeds maximum object size '9223372036854775807'
   11 | string f1[MAXN1], f2[MAXN1];
      |                      ^~~~~

Code

#include <bits/stdc++.h>
using namespace std;
 
# define MAXSUM 1000001 
 
typedef long long ll; 
const ll INF = 1e18;
const int MAXN1 = 1e67
const int MAXN2 = 1e8;
 
string f1[MAXN1], f2[MAXN1];
 
ll n, q; 
ll a, b;
 
string gen_random(const int len) {
    static const char alphanum[] = "abcdefghijklmnopqrstuvwxyz";
    std::string tmp_s;
    tmp_s.reserve(len);
 
    for (int i = 0; i < len; ++i) {
        tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)];
    }
    
    return tmp_s;
}
 
int F(string s, ll A, ll B) {
    long long h = 0;
    // ll to = 0;
    for (char c : s){
         h = (h * A + c) % B;
        //  to += c;
    }
    // cout << to << endl;
    return h;
}
 
void solve() {
    cin >> a >> b;
    
    
    while(true) {
        string temp = gen_random(7); 
        ll index = F(temp, a, b);
        
        if (index < MAXN1) {
            if (f1[index].length()) {
                cout << f1[index] << ' ' << temp;
                return;
            } else {
                f1[index] = temp;
            }
        }
        // } else {
        //     cout << index << endl;
        //     index -= MAXN1;
        //     cout << index;
        //     if (f2[index].length()) {
        //         cout << f2[index] << ' ' << temp;
        //         return;
        //     } else {
        //         f2[index] = temp;
        //     }
        // }
    }
   
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    solve();
 
    return 0;
}