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

All about problems in Volume 100. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: UVA 10070

Post by brianfry713 » Wed Dec 18, 2013 12:24 am

2100 is huluculu but not leap.
Check input and AC output for thousands of problems on uDebug!

hoimo
New poster
Posts: 18
Joined: Sun Sep 23, 2012 3:43 am

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

Post by hoimo » Wed Dec 18, 2013 3:25 am

Thank u so much that reply.
I got AC.
I dont know why i didn't noticed that.
thanx. :D :lol:

hoimo
New poster
Posts: 18
Joined: Sun Sep 23, 2012 3:43 am

Re: UVA 10070

Post by hoimo » Wed Dec 18, 2013 3:27 am

thank you so much.
i got ac with the help of u. thanx.

atul
New poster
Posts: 7
Joined: Thu Sep 27, 2012 4:21 pm

Re: UVA 10070

Post by atul » Tue Jan 07, 2014 5:45 pm

Why Wrong Ans Plz help

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
//freopen("in.txt", "r", stdin);
long long int t = 0;
string s;
while(cin >> s){
++t;
long long int l = s.size();
long long int a55 = 0, a15 = 0, a4 = 0, a100 = 0, a400 = 0;
for(long int i = 0; i < l; i++){
a55 = ((a55*10) + (s - 48)) % 55;
a15 = ((a15*10) + (s - 48)) % 15;
a100 = ((a100*10) + (s - 48)) % 100;
a4 = ((a4*10) + (s - 48)) % 4;
a400 = ((a400*10) + (s - 48)) % 400;
}
if(t > 1)
cout << endl;
bool flag = true;
if(a400 == 0 || (a4 == 0 && a100 != 0)){
cout << "This is leap year." << endl;
flag = false;
}
if(a15 % 15 == 0){
cout << "This is hulukulu festival year." << endl;
flag = false;
}
if((a400 == 0 || (a4 == 0 && a100 != 0))){
if( a55 == 0)
cout << "This is bulukulu festival year." << endl;
flag = false;
}
if(flag){
cout << "This is an ordinary year." << endl;
}
}
return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: UVA 10070

Post by brianfry713 » Tue Jan 07, 2014 10:37 pm

huluculu is spelled wrong
Check input and AC output for thousands of problems on uDebug!

atul
New poster
Posts: 7
Joined: Thu Sep 27, 2012 4:21 pm

Re: UVA 10070

Post by atul » Wed Jan 08, 2014 2:04 am

Thanks a lot

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: UVA 10070

Post by brianfry713 » Sun Jan 19, 2014 2:19 am

Input:

Code: Select all

2000
12000
22000
32000
42000
52000
62000
Output should be:

Code: Select all

This is leap year.

This is leap year.
This is huluculu festival year.

This is leap year.
This is bulukulu festival year.

This is leap year.

This is leap year.
This is huluculu festival year.

This is leap year.

This is leap year.
Check input and AC output for thousands of problems on uDebug!

ultima_key
New poster
Posts: 10
Joined: Tue Mar 25, 2014 12:50 pm

Re: UVA 10070

Post by ultima_key » Fri Mar 28, 2014 2:46 pm

Code: Select all

#include <iostream>
using namespace std;

int main(){
	long long year;
	while(cin >> year){
		bool leap = false, huluculu = false, bulukulu = false;
		if(year%4 == 0 && year%400 == 0) leap = true;
		else if(year%100 == 0) leap = false;
		if(year%15 == 0) huluculu = true;
		if(year%55 == 0 && leap) bulukulu = true;
		
		if(leap) cout << "This is leap year." << endl;
		if(huluculu) cout << "This is huluculu festival year." << endl;
		if(bulukulu) cout << "This is bulukulu festival year." << endl;
		if(!leap && !huluculu && !bulukulu) cout << "This is an ordinary year." << endl;
		cout << endl;
	}
}
Everything that I input is correct. But still it gives back a WA verdict. What could be the problem of my code?

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: UVA 10070

Post by brianfry713 » Fri Mar 28, 2014 9:35 pm

The year can be bigger than a long long can handle, my AC code assumes a line can be up to 1000000 digits long.
Check input and AC output for thousands of problems on uDebug!

ultima_key
New poster
Posts: 10
Joined: Tue Mar 25, 2014 12:50 pm

Re: UVA 10070

Post by ultima_key » Sat Mar 29, 2014 12:40 pm

So I will create a char, say char num[1000000], but here's the question:

How will I be able to convert every character to an integer so that i could check it if it is leap year or huluculu or bulukulu. Sorry. I'm still a newbie programmer.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: UVA 10070

Post by brianfry713 » Mon Mar 31, 2014 11:20 pm

You'll need to program a bigint mod function - search the web for examples. Or you could use Java's bigInteger.
Check input and AC output for thousands of problems on uDebug!

ultima_key
New poster
Posts: 10
Joined: Tue Mar 25, 2014 12:50 pm

Re: UVA 10070

Post by ultima_key » Wed Apr 02, 2014 3:54 pm

brianfry713 wrote:You'll need to program a bigint mod function - search the web for examples. Or you could use Java's bigInteger.

Code: Select all

import java.math.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner cin = new Scanner(System.in);
		BigInteger n;
		while(cin.hasNext()){
			n = cin.nextBigInteger();
			BigInteger fif = new BigInteger("15");
			BigInteger zero = new BigInteger("0");
			BigInteger hun = new BigInteger("100");
			BigInteger fhun = new BigInteger("400");
			BigInteger ffive = new BigInteger("55");
			BigInteger four = new BigInteger("4");
			
			boolean leap = false, huluculu = false, bulukulu = false;
			if(n.mod(four).equals(zero) && n.mod(fhun).equals(zero)) leap = true;
			else if(n.mod(hun).equals(zero)) leap = false;
			if(n.mod(fif).equals(zero)) huluculu = true;
			if(n.mod(ffive).equals(zero) && leap) bulukulu = true;
			
			if(leap) System.out.println("This is leap year.");
			if(huluculu) System.out.println("This is huluculu festival year.");
			if(bulukulu) System.out.println("This is bulukulu festival year.");
			if(!leap && !huluculu && !bulukulu) System.out.println("This is an ordinary year.");
			System.out.println();
		}
	}
}
Changed my code to Java using BigInteger yet I still receive a WA response from the judge. What could be the problem?

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: UVA 10070

Post by brianfry713 » Wed Apr 02, 2014 9:54 pm

A blank line should separate the output for each line of input. Don't print an extra blank line at the end.
Check input and AC output for thousands of problems on uDebug!

partha31
New poster
Posts: 2
Joined: Tue Jun 10, 2014 11:09 pm

Re: UVA 10070

Post by partha31 » Tue Jun 10, 2014 11:26 pm

#include<stdio.h>
int main()
{
int n,a,b,c,count;
while(scanf("%d",&n)==1)
{
b==0;
count=0;
if(n%4==0&&n%100!=0||n%400==0)
{
printf("This is leap year.\n");
b++;
count++;
}
if(n%15==0)
{
printf("This is huluculu festival year.\n");
count++;
}
if(n%55==0&&b==1)
{
printf("This is bulukulu festival year.\n");
count++;
}
if(count==0)
printf("This is an ordinary year.\n");
}
return 0;
}
why is this getting WA

lbv
Experienced poster
Posts: 128
Joined: Tue Nov 29, 2011 8:40 am

Re: UVA 10070

Post by lbv » Wed Jun 11, 2014 8:20 pm

partha31 wrote: why is this getting WA
Your program doesn't pass the sample tests from the problem statement. Notice that blank lines are significant and the output from your program should match the expected output exactly.

Also try configuring your compiler to show you all warnings, and pay attention to those messages. For example, when I compiled your code I noticed this, which seems important:

Code: Select all

p.c: In function ‘main’:
p.c:7:1: warning: statement with no effect [-Wunused-value]
 b==0;
 ^
p.c:9:10: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
 if(n%4==0&&n%100!=0||n%400==0)
          ^
P.S. When posting source code in the forums, please use the "code" tags (see the buttons on the top while editing your message).

Post Reply

Return to “Volume 100 (10000-10099)”