Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main () {
- long long int d, n, a, b;
- int suma=0;
- cin >> d >> n;
- bool tab[d];
- for (int i=0; i<=d; i++) {
- tab[i] = 0;
- }
- for (int i=0; i<n; i++) {
- cin >> a >> b;
- for (a;a<=d;a=a+b){
- tab[a] = 1;
- }
- }
- for (int i=0; i<=d; i++) {
- if (tab[i]==1) {
- suma = suma+1;
- }
- }
- cout << suma;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement