Advertisement
pablo7890

lz1 - ogrodzenie

Feb 28th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main () {
  4.     long long int d, n, a, b;
  5.     int suma=0;
  6.     cin >> d >> n;
  7.     bool tab[d];
  8.     for (int i=0; i<=d; i++) {
  9.         tab[i] = 0;
  10.     }
  11.     for (int i=0; i<n; i++) {
  12.         cin >> a >> b;
  13.         for (a;a<=d;a=a+b){
  14.             tab[a] = 1;
  15.         }
  16.     }
  17.     for (int i=0; i<=d; i++) {
  18.         if (tab[i]==1) {
  19.             suma = suma+1;
  20.         }
  21.     }
  22.     cout << suma;  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement