Page 14 of 16

Re: UVA 10070

Posted: Wed Dec 18, 2013 12:24 am
by brianfry713
2100 is huluculu but not leap.

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

Posted: Wed Dec 18, 2013 3:25 am
by hoimo
Thank u so much that reply.
I got AC.
I dont know why i didn't noticed that.
thanx. :D :lol:

Re: UVA 10070

Posted: Wed Dec 18, 2013 3:27 am
by hoimo
thank you so much.
i got ac with the help of u. thanx.

Re: UVA 10070

Posted: Tue Jan 07, 2014 5:45 pm
by atul
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;
}

Re: UVA 10070

Posted: Tue Jan 07, 2014 10:37 pm
by brianfry713
huluculu is spelled wrong

Re: UVA 10070

Posted: Wed Jan 08, 2014 2:04 am
by atul
Thanks a lot

Re: UVA 10070

Posted: Sun Jan 19, 2014 2:19 am
by brianfry713
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.

Re: UVA 10070

Posted: Fri Mar 28, 2014 2:46 pm
by ultima_key

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?

Re: UVA 10070

Posted: Fri Mar 28, 2014 9:35 pm
by brianfry713
The year can be bigger than a long long can handle, my AC code assumes a line can be up to 1000000 digits long.

Re: UVA 10070

Posted: Sat Mar 29, 2014 12:40 pm
by ultima_key
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.

Re: UVA 10070

Posted: Mon Mar 31, 2014 11:20 pm
by brianfry713
You'll need to program a bigint mod function - search the web for examples. Or you could use Java's bigInteger.

Re: UVA 10070

Posted: Wed Apr 02, 2014 3:54 pm
by ultima_key
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?

Re: UVA 10070

Posted: Wed Apr 02, 2014 9:54 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: UVA 10070

Posted: Tue Jun 10, 2014 11:26 pm
by partha31
#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

Re: UVA 10070

Posted: Wed Jun 11, 2014 8:20 pm
by lbv
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).