Cod sursa(job #3276695)

Utilizator bogdan1479Luca Bogdan Alexandru bogdan1479 Data 14 februarie 2025 10:36:57
Problema Mins Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <fstream>
#include <bitset>

using namespace std;

const int NMAX = 5000;

ifstream fin("mins.in");
ofstream fout("mins.out");

bitset<NMAX> b[NMAX];
int c, d, sol;

int main()
{
    fin >> c >> d;
    for(int i = 1; i < d; ++i)
        for(int j = 1; j < c; ++j)
            if(!b[i][j])
            {
                ++sol;
                int x = i, y = j;
                do
                {
                    b[x][y] = 1;
                    x += i, y += j;
                }
                while(x < d && y < c);
            }
    fout << sol;
    return 0;
}