Submission #622619

# Submission time Handle Problem Language Result Execution time Memory
622619 2022-08-04T12:29:47 Z bigo Strange Device (APIO19_strange_device) C++14
5 / 100
360 ms 12592 KB
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll mod = 1e9 + 7;
const ll mod1 = 998244353;
#define all(a) a.begin(),a.end()

int gcd(int x, int y) {
	if (x < y)
		swap(x, y);
	if (y == 0)
		return x;
	x %= y;
	return gcd(y, x);
}
int main() {
	ios::sync_with_stdio(false);
	ll n, a, b;
	cin >> n >> a >> b;
	ll ju = (b + 1) % a;
	ll m = a / (gcd(a, ju));
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		ll l, r;
		cin >> l >> r;
		ll num = (r - l + 1);
		num /= b;
		if (num < m) {
			ans += num * b;
			ans += (r - l + 1) % b;
		}
		else
			ans += m*b;
	}
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 4 ms 688 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 232 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 2 ms 356 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 360 ms 12592 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 360 ms 12592 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 360 ms 12592 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 33 ms 3896 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 4 ms 688 KB Output isn't correct
3 Halted 0 ms 0 KB -