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 and ...
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA 10070
Check input and AC output for thousands of problems on uDebug!
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
10070- Leap year or not Leap year
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?
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;
}
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Re: 1070- Leap year or not Leap year
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![:wink:](./images/smilies/icon_wink.gif)
By the way problems number is 10070 not 1070.
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
If you have problems read that posts.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.
![:wink:](./images/smilies/icon_wink.gif)
By the way problems number is 10070 not 1070.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 1070- Leap year or not Leap year
Thank you !! ![:P](./images/smilies/icon_razz.gif)
![:P](./images/smilies/icon_razz.gif)
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 1070- Leap year or not Leap year
Don't read from a file.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 2
- Joined: Thu Aug 14, 2014 2:25 pm
Re: 10070 - Leap Year or Not Leap Year and …
could anyone tell me why i'm getting WA ?
thank you in advance
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 …
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.
INPUTOUTPUT2200
3000
6000
2000
10500
5500& one thing ur code is giving a extra blank line after last output. be careful about this.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.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
-
- New poster
- Posts: 10
- Joined: Sat Sep 06, 2014 12:44 pm
Re: 10070 - Leap Year or Not Leap Year and ...
please help me . i cannot find why wrong ans :
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();
}
}
}
![:roll:](./images/smilies/icon_rolleyes.gif)
![:oops:](./images/smilies/icon_redface.gif)
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();
}
}
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10070 - Leap Year or Not Leap Year and ...
A blank line should separate the output for each line of input.
Don't print an extra blank line at the end.
Don't print an extra blank line at the end.
Check input and AC output for thousands of problems on uDebug!
Re: 10070 - Leap Year or Not Leap Year and ...
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
Last edited by bgcsaif on Mon Oct 06, 2014 7:45 pm, edited 1 time in total.
Re: 10070 - Leap Year or Not Leap Year and ...
Try to check input in this thread first. I left 3 cases which your code fails.
![8)](./images/smilies/icon_cool.gif)
Don't forget to remove your code after getting accepted.alu_mathics wrote:try with thisOutput:456464484515645448647512343674234567564234564784234564754742345647424500
838286831260478655
838286831260478655If you can pass this input , hope your code will get A.C.This is huluculu festival year.
This is huluculu festival year.
This is huluculu festival year.
![8)](./images/smilies/icon_cool.gif)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Re: 10070 - Leap Year or Not Leap Year and ...
![:(](./images/smilies/icon_frown.gif)
Code: Select all
Thanks! Code removed after AC
Last edited by bgcsaif on Mon Oct 06, 2014 7:47 pm, edited 1 time in total.
Re: 10070 - Leap Year or Not Leap Year and ...
Don't print blank line after last case.A blank line should separate the output for each line of input
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
-
- New poster
- Posts: 32
- Joined: Fri Oct 10, 2014 1:10 pm
- Location: Sylhet, Bangladesh
please help:(
what is the problem in my code
got WA three times
is there any critical input...
![:(](./images/smilies/icon_frown.gif)
got WA three times
![:(](./images/smilies/icon_frown.gif)
is there any critical input...
Code: Select all
GOT AC
Last edited by gautamzero on Fri Oct 10, 2014 6:43 pm, edited 1 time in total.
Re: 10070 - Leap Year or Not Leap Year and ...
You are printing extra character after last case.
Change reading to
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");
}
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman