// lab01.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

//#define M 10000

unsigned int gist[10];
//int n = 10000;
const int N=10000;

unsigned inverse(unsigned a, unsigned m) {
    for (int i = 1; i < m; ++i)
        if ((a * i) % m == 1)
            return i;
}

void main()
{
    const unsigned a = 237, c = 161, m = (1 << 7) - 1;
    int x0, x;
    double u0, u;
    x0 = 1;
    for (int i = 1; i <= N; ++i) {
        x = (a * x0 + c) % m;
        u = (double)x / m;
        int j = u * 10;
        gist[j]++;
        x0 = x;
    }
    for (int j = 0; j < 10; j++)
        cout << j << ": " << gist[j] << endl;
    cout << endl << endl << inverse(15, 23) << endl;
}
