A Solution For The "Hartals" Problem
Join the DZone community and get the full member experience.
Join For FreeA solution for the "Hartals" problem.
Problem description:
http://icpcres.ecs.baylor.edu/onlinejudge/external/100/10050.html
Author: Joana Matos Fonseca da Trindade
Date: 2008.04.06
/*
* Solution for the "Hartals" problem.
* UVa ID: 10050
*/
#include
#define NDAYS 3651
using namespace std;
/* simulation time (in days) */
int st[NDAYS];
/* main */
int main (int argc, const char *argv[]) {
int nc; /* number of cases */
int nd; /* number of days */
int np; /* number of political parties */
int h; /* current hartal number */
int dl; /* days lost */
cin >> nc;
/* for each case.. */
for (int i=0; i> nd;
cin >> np;
/* initialize simulation table */
for (int j=0; j<=nd; j++) {
st[j] = 0;
}
dl = 0; /* init days lost counter */
/* update with hartal for each party */
for (int j=0; j> h;
for (int k=1; k*h-1<=nd; k++) {
st[k*h-1] = 1; /* set lost day flag */
}
}
/* calculate number of days lost */
for (int j=0; j
Opinions expressed by DZone contributors are their own.
Comments