algorithm

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub drken1215/algorithm

:warning: tests/ABC_334_B.cpp

Depends on

Code

#define PROBLEM "https://atcoder.jp/contests/abc334/tasks/abc334_b"

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

#include "floor_ceil.hpp"

int main() {
    long long A, M, L, R;
    cin >> A >> M >> L >> R;
    long long l = ceil(L - A, M), r = floor(R - A, M);
    cout << r - l + 1 << endl;
}
#line 1 "tests/ABC_334_B.cpp"
#define PROBLEM "https://atcoder.jp/contests/abc334/tasks/abc334_b"

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

#line 3 "Others/floor_ceil.hpp"
using namespace std;

// floor, ceil
template<class T> T floor(T a, T b) {
    if (a % b == 0 || a >= 0) return a / b;
    else return -((-a) / b) - 1;
}
template<class T> T ceil(T x, T y) {
    return floor(x + y - 1, y);
}
#line 7 "tests/ABC_334_B.cpp"

int main() {
    long long A, M, L, R;
    cin >> A >> M >> L >> R;
    long long l = ceil(L - A, M), r = floor(R - A, M);
    cout << r - l + 1 << endl;
}
Back to top page