Pagini recente » Rating Iancu Alexandru Dorian (AlexDeKinai) | Cod sursa (job #574322) | Cod sursa (job #1121823) | Cod sursa (job #3169371) | Cod sursa (job #541537)
Cod sursa(job #541537)
// http://infoarena.ro/problema/light2
#include <fstream>
using namespace std;
#define maxSize 1000000
ifstream in("light2.in");
ofstream out("light2.out");
int length,kids,tmp;
int counter;
bool light[maxSize];
int main() {
in >> length;
in >> kids;
for(int i=1;i<=kids;i++) {
in >> tmp;
for(int k=tmp;k<=length;k+=tmp)
if(light[k]) {
light[k] = false;
counter--;
}
else {
light[k] = true;
counter++;
}
}
out << counter;
in.close();
out.close();
}