10050 - Hartals
Moderator: Board moderators
-
- New poster
- Posts: 38
- Joined: Wed Dec 05, 2012 11:29 pm
Re: 10050 - Hartals
@ brianfry713:Thanks for your reply . but I checked your link with I/O. There is a problem in your output .
When input is :
3585
2
908
1112
Correct Ans would be 5 ( http://uvatoolkit.com/problemssolve.php ). My code also generate this answer.
but in your link ,it is 66
When input is :
3585
2
908
1112
Correct Ans would be 5 ( http://uvatoolkit.com/problemssolve.php ). My code also generate this answer.
but in your link ,it is 66
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10050 - Hartals
Yes for input: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.
Code: Select all
1
3585
2
908
1112
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 38
- Joined: Wed Dec 05, 2012 11:29 pm
Re: 10050 - Hartals
@ 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
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
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10050 - Hartals
You need to initialize the D array before you use it.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 38
- Joined: Wed Dec 05, 2012 11:29 pm
Re: 10050 - Hartals
brianfry713: Finally I got AC
Thank You very much .
![:)](./images/smilies/icon_smile.gif)
10050 - Hartals Why WA?????
Please Help..
getting continuously WA..
here is my code...
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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10050 - Hartals Why WA?????
Post in the appropriate forum, volume C instead of General.
Try running your code on the sample input.
Try running your code on the sample input.
Check input and AC output for thousands of problems on uDebug!
Re: 10050 - Hartals Why WA?????
My code runs well for all sample input...brianfry713 wrote:Post in the appropriate forum, volume C instead of General.
Try running your code on the sample input.
Plz check and help.
![:(](./images/smilies/icon_frown.gif)
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10050 - Hartals Why WA?????
Check input and AC output for thousands of problems on uDebug!
uva 10050 -hartals Why i am getting RE in this code?
i have tested with the sample inputs and it works fine.But uva is giving RE
..please someone help me out.
![:(](./images/smilies/icon_frown.gif)
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?
i got AC using same logic in C++.But using java i am getting RE.Please help me out
![:(](./images/smilies/icon_frown.gif)
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?
See the submission specs for Javamaddi wrote:i got AC using same logic in C++.But using java i am getting RE.Please help me out
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?
memberlist.php?mode=viewprofile&u=99347 thanks a lot man.I have been eagerly waiting for any kind help regarding this.
Finally,got AC.
Finally,got AC.
Re: uva 10050 -hartals Why i am getting RE in this code?
Glad you figured it out.maddi wrote:thanks a lot man.I have been eagerly waiting for any kind help regarding this.
Finally,got AC.
Next time please post in the existing thread for the problem
viewtopic.php?f=9&t=2058&hilit=10050
And do not create a new one.
-
- New poster
- Posts: 1
- Joined: Sat Sep 19, 2015 8:35 am
Re: 10050 - Hartals
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[3650]={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;
}