Page 4 of 4

### Re: 10050 - Hartals

Posted: Tue May 21, 2013 3:26 pm
When input is :
3585
2
908
1112

Correct Ans would be 5 ( http://uvatoolkit.com/problemssolve.php ). My code also generate this answer.

### Re: 10050 - Hartals

Posted: Tue May 21, 2013 10:01 pm
Yes for input:

Code: Select all

``````1
3585
2
908
1112``````
AC output is 5. This link https://ideone.com/D1195a is YOUR code, not mine, it's what you posted in this thread. It does not produce the correct answer.

### Re: 10050 - Hartals

Posted: Wed May 22, 2013 9:34 am
@ brianfry713: I'm confused here :S
I checked my code by Microsoft Visual Studio 2005 and it gives following input -output

Input:
1
3585
2
908
1112

Output:
5

but here (https://ideone.com/D1195a )
sometimes it gives 66 and sometimes 57

### Re: 10050 - Hartals

Posted: Wed May 22, 2013 11:04 pm
You need to initialize the D array before you use it.

### Re: 10050 - Hartals

Posted: Thu May 23, 2013 10:32 am
brianfry713: Finally I got AC Thank You very much .

### 10050 - Hartals Why WA?????

Posted: Sat Mar 08, 2014 9:12 pm
getting continuously WA..

here is my code...

Code: Select all

``````#include <iostream>
#include <cstdio>

using namespace std;

int main(){
int t;
scanf("%d",&t);
while(t--){
int n,p,hartal;
scanf("%d %d",&n,&p);
int res[n];
for(int i=0;i<n;i++)res[i]=0;
for(int i=0;i<p;i++){
scanf("%d",&hartal);
for(int j=hartal;j<n;j+=hartal){
res[j]=1;
}
}
p=0;
for(int i=0;i<n;i++){
if((i+1)%7!=0&&i%7!=0&&res[i]==1)p++;
}
printf("%d\n",p);
}
return 0;
}
``````

### Re: 10050 - Hartals Why WA?????

Posted: Mon Mar 10, 2014 8:41 pm
Post in the appropriate forum, volume C instead of General.
Try running your code on the sample input.

### Re: 10050 - Hartals Why WA?????

Posted: Mon Mar 10, 2014 9:36 pm
brianfry713 wrote:Post in the appropriate forum, volume C instead of General.
Try running your code on the sample input.
My code runs well for all sample input...
Plz check and help. ### Re: 10050 - Hartals Why WA?????

Posted: Tue Mar 11, 2014 10:20 pm

### uva 10050 -hartals Why i am getting RE in this code?

Posted: Fri Jul 31, 2015 2:22 pm
i have tested with the sample inputs and it works fine.But uva is giving RE ..please someone help me out.

Code: Select all

``````package pkg10050.hartals;

import java.util.Arrays;
import java.util.Scanner;

class Hartals {

public static void main(String[] args) {
new Hartals().run();
}

void run() {
Scanner in = new Scanner(System.in);
int days[];
int Total_case, No_of_days, Total_Parties, p;

Total_case = in.nextInt();

for (int j = 1; j <= Total_case; j++) {

No_of_days = in.nextInt();

days = new int[No_of_days+1];
Arrays.fill(days, -1);

for (int k = 6; k <= No_of_days; k += 7) {
days[k] = 0;
}

Total_Parties = in.nextInt();
int total_hartals = 0;

for (int i = 1; i <= Total_Parties; i++) {

p = in.nextInt();
int hartal_days = p;

while (hartal_days <= No_of_days) {

if (hartal_days % 7 != 0 && days[hartal_days] == -1) {
total_hartals++;
days[hartal_days] = 1;
}
hartal_days += p;
}
}
System.out.println(total_hartals);
}
}
}
``````

### uva 10050 -hartals Why i am getting RE in this code?

Posted: Sat Aug 01, 2015 5:13 am
i got AC using same logic in C++.But using java i am getting RE.Please help me out Code: Select all

``````//package pkg10050.hartals;

import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

class Hartals {

public static void main(String[] args) throws FileNotFoundException {

new Hartals().run();
}

void run() throws FileNotFoundException {
//       System.setOut(new PrintStream(new FileOutputStream("o.txt")));
//       System.setIn(new FileInputStream(new File("i.txt")));

Scanner in = new Scanner(System.in);
int days[];
int Total_case, No_of_days, Total_Parties, p;

Total_case = in.nextInt();

for (int j = 1; j <= Total_case; j++) {

No_of_days = in.nextInt();
days = new int[No_of_days+1];
Arrays.fill(days, -1);

Total_Parties = in.nextInt();
int total_hartals = 0;

for (int i = 1; i <= Total_Parties; i++) {

p = in.nextInt();
int hartal_days = p;

while (hartal_days <= No_of_days) {

if (hartal_days%7!=6 && hartal_days % 7 != 0 && days[hartal_days] == -1) {
total_hartals++;
days[hartal_days] = 1;
}
hartal_days += p;
}
}
System.out.println(total_hartals);
}
}
}
``````

### Re: uva 10050 -hartals Why i am getting RE in this code?

Posted: Mon Aug 03, 2015 9:52 am
maddi wrote:i got AC using same logic in C++.But using java i am getting RE.Please help me out See the submission specs for Java

https://uva.onlinejudge.org/index.php?o ... &Itemid=30

Your class needs to changed from "Hartals" to "Main".

### Re: uva 10050 -hartals Why i am getting RE in this code?

Posted: Mon Aug 03, 2015 9:27 pm
memberlist.php?mode=viewprofile&u=99347 thanks a lot man.I have been eagerly waiting for any kind help regarding this.
Finally,got AC.

### Re: uva 10050 -hartals Why i am getting RE in this code?

Posted: Tue Aug 04, 2015 7:01 am
maddi wrote:thanks a lot man.I have been eagerly waiting for any kind help regarding this.
Finally,got AC.

viewtopic.php?f=9&t=2058&hilit=10050

And do not create a new one.

### Re: 10050 - Hartals

Posted: Sat Sep 19, 2015 9:01 am
Plz help...What's wrong with this code??

Code: Select all

``````
#include <stdio.h>

int main()
{
int T=0;
scanf("%d", &T);
for(int cnt=0; cnt<T; cnt++)
{
int n=0, p=0, k=0;
int arr={0};
scanf("%d", &n);
scanf("%d", &p);
for(int i=0; i<p; i++)
{
int h=0;
scanf("%d", &h);
for(int j=1; j<=n/h; j++)
{
if((h*j+1)%7==0)    continue;
arr[h*j]=1;
}
}
for(int l=1; l<=n; l++)
{
if(arr[l]==1)   k++;
else continue;
}
printf("%d\n", k);
}
return 0;

}``````