Language: C++

#include <bits/stdc++.h>
using namespace std;

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
//int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
//int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
//int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
//int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}
int GCD(int a, int b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/

int f(int a, int b, int &c)
{
	int cnt{};
	int m = a;
	if(a < c){
		m = a+(a%c)-1;
	}
	else if(a > c){
		m = a+(a%c)+1;
	}

	for(int i = m; i <= b; i += c)
	{
		cnt++;
	}

	return cnt;
}

#define int int64_t
signed main()
{
	int a, b, c, d; cin >> a >> b >> c >> d;
	
	int ans = b-a+1-( f(a,b,c)+f(a,b,d)-f(a,b,c*d) );
	cout << ans << '\n';
}
/*
切り上げ
(A+B-1)/B
(A+9)/10*10
 
^^^おかしい
xをyの倍数へ(切り上げ)
x+(x%y)
^^^
↓
int m = a;
if(a%c != 0){
	m = a - a%c + c;
}
 
x以下なyの倍数の個数
x/y(切り捨て)
 
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:81:33: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'int64_t' {aka 'long int'}
   81 |         int ans = b-a+1-( f(a,b,c)+f(a,b,d)-f(a,b,c*d) );
      |                                 ^
a.cc:57:26: note:   initializing argument 3 of 'int f(int, int, int&)'
   57 | int f(int a, int b, int &c)
      |                     ~~~~~^
a.cc:81:42: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'int64_t' {aka 'long int'}
   81 |         int ans = b-a+1-( f(a,b,c)+f(a,b,d)-f(a,b,c*d) );
      |                                          ^
a.cc:57:26: note:   initializing argument 3 of 'int f(int, int, int&)'
   57 | int f(int a, int b, int &c)
      |                     ~~~~~^
a.cc:81:52: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'int64_t' {aka 'long int'}
   81 |         int ans = b-a+1-( f(a,b,c)+f(a,b,d)-f(a,b,c*d) );
      |                                                   ~^~
a.cc:57:26: note:   initializing argument 3 of 'int f(int, int, int&)'
   57 | int f(int a, int b, int &c)
      |                     ~~~~~^