Submission #769155

# Submission time Handle Problem Language Result Execution time Memory
769155 2023-06-29T08:58:11 Z 1ne Strange Device (APIO19_strange_device) C++14
0 / 100
1 ms 212 KB
/*
*  author : Apiram                  
*  created: 29.06.2023 02:40:46
*/

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//x = t - [t / A] * A + [t / B] - [[t / B] / A] * A
	//y = t - [t / B] * B -> totally B values atmost
	//t2 = k * t;
	//(t2 - t) - (A * [t2 / A] - [t / A] * A) + ([t2 / B] - [t / B]) - ([[t2 / B] / A] * A - [[t / B] / A] * A) == 0
	//t % A ==0 && t % B == 0 && t % (A * B) == 0,
	//t2 - t - (t2 - t) + ((t2 - t) / B) - (t2 - t) / B = 0
	//therefore whenever t2 % A * B == 0, and t2 % t == 0 then it will produce the same answer 
	long long n,A,B;cin>>n>>A>>B;
	long long sum = 0;
	for (int i = 0;i<n;++i){
		long long l,r;cin>>l>>r;
		long long ans = min(r - l + 1,B);
		ans+=(r - l + 1 -  ans - (r / (A * B) - (l - 1) / (A * B)));
		cout<<ans<<'\n';
		sum+=ans;
	}
	cout<<sum<<'\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -