10070 - Leap Year or Not Leap Year and ...
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA 10070
2100 is huluculu but not leap.
Check input and AC output for thousands of problems on uDebug!
Re: 10070 - Leap Year or Not Leap Year and ...
Thank u so much that reply.
I got AC.
I dont know why i didn't noticed that.
thanx.

I got AC.
I dont know why i didn't noticed that.
thanx.


Re: UVA 10070
thank you so much.
i got ac with the help of u. thanx.
i got ac with the help of u. thanx.
Re: UVA 10070
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;
}
#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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA 10070
huluculu is spelled wrong
Check input and AC output for thousands of problems on uDebug!
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA 10070
Input:Output should be:
Code: Select all
2000
12000
22000
32000
42000
52000
62000
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!
-
- New poster
- Posts: 10
- Joined: Tue Mar 25, 2014 12:50 pm
Re: UVA 10070
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;
}
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA 10070
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!
-
- New poster
- Posts: 10
- Joined: Tue Mar 25, 2014 12:50 pm
Re: UVA 10070
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.
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.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA 10070
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!
-
- New poster
- Posts: 10
- Joined: Tue Mar 25, 2014 12:50 pm
Re: UVA 10070
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();
}
}
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA 10070
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!
Re: UVA 10070
#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
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
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.partha31 wrote: why is this getting WA
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)
^