Page 15 of 16

Re: UVA 10070

Posted: Wed Jun 11, 2014 11:04 pm
by brianfry713
brianfry713 wrote:The year can be bigger than a long long can handle, my AC code assumes a line can be up to 1000000 digits long.

10070- Leap year or not Leap year

Posted: Wed Jul 16, 2014 1:14 pm
by Shahidul.CSE
Why having WA with my code?

I am getting correct output of given simple input.
And also getting correct output as:
for 2100 huluculu,
for 22055 ordinary,
for 16555 ordinary .

I checked for int type also.
Where is the wrong?

Code: Select all

#include<stdio.h>
int main()
{
    freopen("10070.txt", "r", stdin);
    long long int lp,h,b,yr;
    while(scanf("%lld",&yr)!=EOF)
    {
        lp=h=b=0;
        if((yr%4==0 && yr%100!=0) || yr%400==0)
            lp=1;
        if(yr%15==0)
            h=1;
        if(lp==1 && yr%55==0)
            b=1;
        if(lp==1)
            printf("This is leap year.\n");
        if(h==1)
            printf("This is huluculu festival year.\n");
        if(b==1)
            printf("This is bulukulu festival year.\n");
        if(lp==0 && h==0 && b==0)
            printf("This is an ordinary year.\n");

        printf("\n");


    }
    return 0;
}

Re: 1070- Leap year or not Leap year

Posted: Wed Jul 16, 2014 2:07 pm
by lighted
If there is a thread about your problem, please use it.
Don't open new thread. First of all use search by problem number (10070 for this problem)
http://acm.uva.es/board/search.php?keyw ... b3decb6507

For this problem there are many existing threads. One of them is below
http://acm.uva.es/board/viewtopic.php?f ... 07#p369473

The main reason why you get WA is the post written there
brianfry713 wrote:The year can be bigger than a long long can handle, my AC code assumes a line can be up to 1000000 digits long.
If you have problems read that posts. :wink:

By the way problems number is 10070 not 1070.

Re: 1070- Leap year or not Leap year

Posted: Wed Jul 16, 2014 2:17 pm
by Shahidul.CSE
Thank you !! :P

Re: 1070- Leap year or not Leap year

Posted: Wed Jul 16, 2014 7:45 pm
by brianfry713
Don't read from a file.

Re: 10070 - Leap Year or Not Leap Year and …

Posted: Thu Aug 14, 2014 2:27 pm
by tausiftt5238
could anyone tell me why i'm getting WA ?
thank you in advance

Code: Select all

#include <stdio.h>
#include <string.h>
int div_4(char a[])
{
	int i,remainder = 0;
	for(i=0;a[i]!=0;i++)
	{
		remainder = (remainder*10 + a[i]-48)%4;
	}
	if(remainder == 0)
		return 1;
	else
		return 0;
}
int div_15(char a[])
{
	int i,remainder = 0;
	for(i=0;a[i]!=0;i++)
	{
		remainder = (remainder*10 + a[i]-48)%15;
	}
	if(remainder == 0)
		return 1;
	else
		return 0;
}
int div_55(char a[])
{
	int i,remainder = 0;
	for(i=0;a[i]!=0;i++)
	{
		remainder = (remainder*10 + a[i]-48)%55;
	}
	if(remainder == 0)
		return 1;
	else
		return 0;
}
int div_100(char a[])
{
	int i,remainder = 0;
	for(i=0;a[i]!=0;i++)
	{
		remainder = (remainder*10 + a[i]-48)%100;
	}
	if(remainder == 0)
		return 1;
	else
		return 0;
}
int div_400(char a[])
{
	int i,remainder = 0;
	for(i=0;a[i]!=0;i++)
	{
		remainder = (remainder*10 + a[i]-48)%400;
	}
	if(remainder == 0)
		return 1;
	else
		return 0;
}
int main()
{
	char a[1000000];
	int b4,b15,b55,b100,b400;
	int flag,leap;
	int start = 0;
	while(gets(a)!=NULL)
	{
		leap = flag = 0;
		if(start != 0)
			printf("\n");
		b4 = div_4(a);
		b15 = div_15(a);
		b55 = div_55(a);
		b100 = div_100(a);
		b400 = div_400(a);
		if((b4==1&&b100!=0)||(b400))
		{
			printf("This is leap year.\n");
			leap = 1;
			flag = 1;
		}
		if(b15)
		{
			printf("This is huluculu festival year.\n");
			flag = 1;
		}
		if(b55)
		{
			if(leap == 1)
				printf("This is bulukulu festival year.\n");
		}
		if(flag != 1)
			printf("This is an ordinary year.\n");
		start = 1;
	}
	return 0;
}

Re: 10070 - Leap Year or Not Leap Year and …

Posted: Thu Aug 14, 2014 4:27 pm
by lighted
You must check input in this thread first. Your program gives wrong output. For example
osan wrote:please check this input & output. i hope these will help u.

INPUT
2200
3000
6000
2000
10500
5500
OUTPUT
This is an ordinary year.

This is huluculu festival year.

This is leap year.
This is huluculu festival year.

This is leap year.

This is huluculu festival year.

This is an ordinary year.
& one thing ur code is giving a extra blank line after last output. be careful about this.

Re: 10070 - Leap Year or Not Leap Year and ...

Posted: Wed Sep 17, 2014 7:34 pm
by nasim.ruet
please help me . i cannot find why wrong ans : :roll: :oops:


import java.math.BigInteger;
import java.util.Scanner;

public class Main {

private static Scanner scanner;

public static void main(String[] args) {
scanner = new Scanner(System.in);
BigInteger number;
boolean check;

while (scanner.hasNext()) {
number = scanner.nextBigInteger();

check=false;
if (number.mod(BigInteger.valueOf(4)).equals(BigInteger.ZERO)) {
if (number.mod(BigInteger.valueOf(100)).equals(BigInteger.ZERO)) {
if (number.mod(BigInteger.valueOf(400)).equals(BigInteger.ZERO)) {
System.out.println("This is leap year.");
check=true;
}
else {
check=false;
}
}
else {
System.out.println("This is leap year.");
check=true;
}
}
if (number.mod(BigInteger.valueOf(15)).equals(BigInteger.ZERO)) {
System.out.println("This is huluculu festival year.");
check=true;
}
if ( check==true && number.mod(BigInteger.valueOf(55)).equals(BigInteger.ZERO))
System.out.println("This is buluculu festival year.");
if(check==false )
System.out.println("This is an ordinary year.");
System.out.println();


}
}

}

Re: 10070 - Leap Year or Not Leap Year and ...

Posted: Wed Sep 17, 2014 8:12 pm
by brianfry713
A blank line should separate the output for each line of input.
Don't print an extra blank line at the end.

Re: 10070 - Leap Year or Not Leap Year and ...

Posted: Mon Oct 06, 2014 10:38 am
by bgcsaif
I tried modular arithmatic to handle big input. I tried many inputs and it is okay. . . . May be i have formatting problems in my code. Can you help me with it please?

Code: Select all

Thanks! Code removed after AC

Re: 10070 - Leap Year or Not Leap Year and ...

Posted: Mon Oct 06, 2014 1:15 pm
by lighted
Try to check input in this thread first. I left 3 cases which your code fails.
alu_mathics wrote:try with this
456464484515645448647512343674234567564234564784234564754742345647424500
838286831260478655
838286831260478655
Output:
This is huluculu festival year.

This is huluculu festival year.

This is huluculu festival year.
If you can pass this input , hope your code will get A.C.
Don't forget to remove your code after getting accepted. 8)

Re: 10070 - Leap Year or Not Leap Year and ...

Posted: Mon Oct 06, 2014 2:43 pm
by bgcsaif
:( I passed those input. But still WA.

Code: Select all

Thanks! Code removed after AC

Re: 10070 - Leap Year or Not Leap Year and ...

Posted: Mon Oct 06, 2014 3:12 pm
by lighted
A blank line should separate the output for each line of input
Don't print blank line after last case.

please help:(

Posted: Fri Oct 10, 2014 1:40 pm
by gautamzero
what is the problem in my code :(
got WA three times :(
is there any critical input...

Code: Select all

GOT AC

Re: 10070 - Leap Year or Not Leap Year and ...

Posted: Fri Oct 10, 2014 3:15 pm
by lighted
You are printing extra character after last case.
Change reading to

Code: Select all

#include <iostream>
..
int ok = 0;
char ch;
while(std::cin.getline(num, 10000))   // gets(num) also works
{
    ..
    if (ok++) puts("");
        
    if(a==1)
    ..
    else if(a==0&&c==0)
        printf("This is an ordinary year.\n");
}