Page 12 of 16
Re: 10070 - Leap Year or Not Leap Year and …
Posted: Mon Mar 11, 2013 11:19 am
by lbv
hello wrote:Why got WA......please help.....
Hi,
- To post code, please use the "code" tags (see the button bar above the message editor).
- I suggest you start by taking the time to read the previous messages from this thread. There's a lot of noise, but also it's easy to spot the useful messages, with tips and test cases for you to try.
- Maybe the number in the input has more than 10^5 characters? My program assumes a maximum number of digits of about 10^6.
Try this case:
Input
Output
Re: 10070 - Leap Year or Not Leap Year and …
Posted: Mon Mar 18, 2013 1:45 pm
by hello
Code: Select all
#include<stdio.h>
#include<string.h>
int main()
{
int c15,c55,c100,c400,c4,ct=1,l,r,t;
char arr[1000000];
while(scanf("%s",arr)==1)
{
int i,k,q=0,rem=0,m=0,x=0,y=0;
i=strlen(arr);
for(k=0; k<i; k++)
{
rem=rem*10;
rem+=arr[k]-48;
rem=rem%55;
q=q*10;
q+=arr[k]-48;
q=q%4;
m=m*10;
m+=arr[k]-48;
m=m%15;
x=x*10;
x+=arr[k]-48;
x=x%100;
y=y*10;
y+=arr[k]-48;
y=y%400;
}
if (rem==0)c55=1; else c55=0;
if (q==0)c4=1;else c4=0;
if(m==0)c15=1;else c15=0;
if(x==0)c100=1;else c100=0;
if(y==0)c400=1;else c400=0;
if(c4 && (!c100 || c400))l=1;else l=0;
if(ct!=1)printf("\n");
if(l){printf("This is leap year.\n");}
if(c15)printf("This is huluculu festival year.\n");
if(l && c55)printf("This is bulukulu festival year.\n");
if(c4==0 && c15==0)printf("This is an ordinary year.\n");
ct++;
}
return 0;
}
still got WA..... Please Someone help me....
Re: 10070 - Leap Year or Not Leap Year and …
Posted: Mon Mar 18, 2013 10:53 pm
by brianfry713
Input: 2200
AC output: This is an ordinary year.
Re: 10070 - Leap Year or Not Leap Year and …
Posted: Sun Jul 21, 2013 4:29 pm
by nildorpon
I got a Compile error.
Please take a look on my code and tell me whats wrong....
import java.io.BufferedInputStream;
import java.util.Scanner;
public class Main {
public static void main(String [] args){
Scanner scanner = new Scanner(new BufferedInputStream(System.in));
while(scanner.hasNext()){
int n = scanner.nextInt();
if(n<2000){
continue;
}
if(((n%4 == 0) && (n%100 != 0)) || (n%400 == 0)){
System.out.println("This is leap year.");
if(n%15 == 0){
System.out.println("This is huluculu festival year.");
}
if(n%55 == 0){
System.out.println("This is Bulukulu festival year.");
}
}else if(n%15 == 0){
System.out.println("This is huluculu festival year.");
}else{
System.out.println("This is an ordinary year.");
}
System.out.println();
}
}
}
Re: 10070 - Leap Year or Not Leap Year and …
Posted: Mon Jul 22, 2013 6:37 am
by brianfry713
You can click My Submissions to see the reason for your Compile Error. That code however gets RE. Try using BigInteger.
Re: 10070 - Leap Year or Not Leap Year and …
Posted: Mon Sep 09, 2013 9:42 pm
by f.maru
Hi guys, this is my program it gave true answer for all test case but i got WA can sb help me plzzzz
Code: Select all
#include<iostream>
#include <math.h>
#include <cmath>
#include <string>
using namespace std;
int sum,m1,m2;
void sumi(string v)
{
m1=m2=sum=0;
for (int t=0;t<v.length();t++)
{
if (t%2==0)
m1+=v[t]-48;
else
m2+=v[t]-48;
sum+=v[t]-48;
}
}
int main()
{
string n;
while(cin>>n)
{
sumi(n);
int w=0,ls=0,p1=n[n.length()-1]-48,p2=n[n.length()-2]-48,p3=n[n.length()-3]-48,p4=n[n.length()-4]-48;
if((p2*10+p1)%4==0 && p1+p2!=0 ||(p4*10+p3)%4==0 && p1+p2==0)
{
w=ls=1;
cout<<"This is leap year."<<endl;
}
if(sum %3==0 & p1 % 5==0)
{
w=1;
cout<<"This is huluculu festival year."<<endl;
}
int m=abs(m1-m2);
if(p1 % 5==0 && m%11==0 && ls==1)
{
w=1;
cout<<"This is bulukulu festival year."<<endl;
}
if(w==0)
cout<<"This is an ordinary year."<<endl;
cout<<endl;
}
}
Re: 10070 - Leap Year or Not Leap Year and …
Posted: Mon Sep 09, 2013 10:58 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: Tue Sep 10, 2013 9:13 am
by f.maru
So how can i notice if it is the last case
and i think i cant use this
Code: Select all
#include<iostream>
#include <math.h>
#include <cmath>
#include <string>
using namespace std;
int sum,m1,m2;
void sumi(string v)
{
m1=m2=sum=0;
for (int t=0;t<v.length();t++)
{
if (t%2==0)
m1+=v[t]-48;
else
m2+=v[t]-48;
sum+=v[t]-48;
}
}
int main()
{
string n;
cin>>n;
sumi(n);
int w=0,ls=0,p1=n[n.length()-1]-48,p2=n[n.length()-2]-48,p3=n[n.length()-3]-48,p4=n[n.length()-4]-48;
if((p2*10+p1)%4==0 && p1+p2!=0 ||(p4*10+p3)%4==0 && p1+p2==0)
{
w=ls=1;
cout<<"This is leap year."<<endl;
}
if(sum %3==0 & p1 % 5==0)
{
w=1;
cout<<"This is huluculu festival year."<<endl;
}
int m=abs(m1-m2);
if(p1 % 5==0 && m%11==0 && ls==1)
{
w=1;
cout<<"This is bulukulu festival year."<<endl;
}
if(w==0)
cout<<"This is an ordinary year."<<endl;
while(cout<<endl && cin>>n)
{
sumi(n);
int w=0,ls=0,p1=n[n.length()-1]-48,p2=n[n.length()-2]-48,p3=n[n.length()-3]-48,p4=n[n.length()-4]-48;
if((p2*10+p1)%4==0 && p1+p2!=0 ||(p4*10+p3)%4==0 && p1+p2==0)
{
w=ls=1;
cout<<"This is leap year."<<endl;
}
if(sum %3==0 & p1 % 5==0)
{
w=1;
cout<<"This is huluculu festival year."<<endl;
}
int m=abs(m1-m2);
if(p1 % 5==0 && m%11==0 && ls==1)
{
w=1;
cout<<"This is bulukulu festival year."<<endl;
}
if(w==0)
cout<<"This is an ordinary year."<<endl;
}
}
but i still get WA
Re: 10070 - Leap Year or Not Leap Year and …
Posted: Wed Sep 11, 2013 12:08 am
by brianfry713
A blank line should separate the output for each line of input. Don't print an extra blank line at the end.
One way to do that would be:
Code: Select all
bool first = true;
while(cin >> n) {
if(!first)
cout << endl;
first = false;
//the rest of your code goes here
}
Re: 10070 - Leap Year or Not Leap Year and …
Posted: Wed Sep 11, 2013 1:25 pm
by f.maru
TNX brianfry713 i got ac
Re: 10070 - Leap Year or Not Leap Year and …
Posted: Fri Sep 13, 2013 5:21 pm
by Salam!
Hi Guys
I Don't Understand why I get wa
plz help Meeeeeeee
Re: 10070 - Leap Year or Not Leap Year and …
Posted: Fri Sep 13, 2013 9:42 pm
by brianfry713
You misspelled bulukulu
Re: 10070 - Leap Year or Not Leap Year and …
Posted: Fri Sep 13, 2013 10:50 pm
by Salam!
brianfry713 wrote:You misspelled bulukulu
Thanks Brianfry713 I got ac
Getting WA - UVA 10070 -Leap Year or Not Leap Year and …
Posted: Thu Sep 26, 2013 5:47 pm
by ijabir
here is my code. help me out
Code: Select all
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int mod(string s, int n)
{
int i=0, rem=0, sz=s.size();
while(i<sz)
{
rem=rem*10+(s[i]-'0');
rem%=n;
i++;
}
return rem%n;
}
int main()
{
int t, cs=0, f, y, r4, r100, r400, r15, r55;
string s;
while(getline(cin,s))
{
t=0;
f=0;
r4=mod(s, 4);
r100=mod(s, 100);
r400=mod(s, 400);
r15=mod(s, 15);
r55=mod(s, 55);
//printf("%d %d %d %d %d", r4, r100, r400, r15, r55);
if(r15==0) t=1;
if(r400==0 || (r4==0 && r100!=0))
{
printf("This is leap year.\n");
if(t==1)
{
printf("This is huluculu festival year.\n");
t=0;
}
if(r55==0) printf("This is bulukulu festival year.\n");
f=1;
}
if(t==1)
{
printf("This is huluculu festival year.\n");
f=1;
}
if(f==0) printf("This is an ordinary year.\n");
printf("\n");
}
return 0;
}
Re: Getting WA - UVA 10070 -Leap Year or Not Leap Year and …
Posted: Fri Sep 27, 2013 11:22 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.