Cod sursa(job #3155099)

Utilizator stefdascalescuStefan Dascalescu stefdascalescu Data 7 octombrie 2023 12:40:14
Problema Pascal Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.74 kb
#include<bits/stdc++.h>
using namespace std;

const int mod = 3000017;

int n, d, sp[3][5000002];

int ratie[3] = {2, 3, 5};
int mat[7][3] = {
	 0, 0, 0,
	 0, 0, 0,
	 1, 0, 0,
	 0, 1, 0,
	 2, 1, 0,
	 0, 0, 1,
	 0, 1, 1
};

int main()
{
	
	ifstream cin("pascal.in");
	ofstream cout("pascal.out");
	
	cin >> n >> d;
	for(int j = 0; j <= 2; j++)
	{
		for(int i = ratie[j]; i <= n; i += ratie[j])
			sp[j][i] = sp[j][i / ratie[j]] + 1;
		for(int i = ratie[j]; i <= n; i++)
			sp[j][i] += sp[j][i-1];
	}
	
	
	int ans = 0;
	for(int i = 0; i <= n; i++)
	{
		bool ok = 1;
		for(int j = 0; j <= 2; j++)
			if(sp[j][n] - sp[j][n-i] - sp[j][i] < mat[d][j])
				ok = 0;
		if(ok)
			ans++;
	}
	
	cout << ans;
	return 0;
}