300 - Maya Calendar
Moderator: Board moderators
Here is my code.
Please help me.
Mamun bhai thanks for helping in advance. 
Please help me.
Code: Select all
Cut After ACC!

Last edited by Sakib on Sat Nov 26, 2005 5:33 am, edited 1 time in total.
/* Sorry For Nothing */
I don't know why you wrote the following line in main()
Remove it. Let it be just
Code: Select all
if(j == 18)j = j * 5;
Code: Select all
j = j * 20;
When you count total number of days you are actually counting how many days are there prior to the beginning of the current month plus the number of days of current month. Note that you return 0 for the first month. So for last month you calculate total number of days before this month (all 20 days) plus number of days of this month.Sakib wrote:ACC now!
But i thought the last month has only five days.
so at the last case i wanted to count 5.
in other case it is 20.
please explain.
and many many thanks again.
300 WA
Why do I got WA?
I need some input data and output data to test my program
Please,help!.....
I need some input data and output data to test my program
Please,help!.....
Code: Select all
#include <cstdio>
#include <cstring>
char *Haab[]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char *Tzolkin[]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int main()
{
int num,i;
int day,year,total,s,k;
char month[20];
scanf("%d",&num);
printf("%d\n",num);
while(num--)
{
scanf("%d. %s %d",&day,month,&year);
for(i=0;i<=18;i++)
if(!strcmp(month,Haab[i]))
break;
total=i*20+day+1+year*365;
//total=20;
s=(total%20==0)?20:total%20;
//printf("[%d]\n",total);
printf("%d %s %d\n",(total%13==0)?13:total%13,Tzolkin[s-1],total/260);
}
return 0;
}
-
- Experienced poster
- Posts: 106
- Joined: Thu Jan 29, 2004 12:07 pm
- Location: Bangladesh
- Contact:
a previous post on this problem :
http://online-judge.uva.es/board/viewtopic.php?t=5131
another ( with a good debugging idea ) :
http://online-judge.uva.es/board/viewtopic.php?t=5989
hope it helps
http://online-judge.uva.es/board/viewtopic.php?t=5131
another ( with a good debugging idea ) :
http://online-judge.uva.es/board/viewtopic.php?t=5989
hope it helps
300 WA
could any one please tell me why got WA on this code:
#include<string.h>
//#include<fstream.h>
#include<iostream.h>
void main(){
// ofstream cout("f:\\my300.out");
// ifstream cin("f:\\300.in");
char habmons[20][10]={
"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh",
"mac","kankin","muan","pax","koyab","cumhu","uayet"};
char tzolkinname[20][10]={"ahau","imix","ik","akbal","kan","chicchan","cimi","manik","lamat",
"muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac"};
long long i,n,year,k,j,day,finaladad,adadperyod,finalyear,mon,mazrab;
char peryod[10],s[10],habmon[10]
;
cin>>n;
cout<<n<<endl;
for(i=0;i<n;i++){
cin>>s;
cin>>habmon;
cin>>year;
for(k=0;k<20;k++)
if(strcmp(habmon,habmons[k])==0){
mon=k;
break;
}
day=mazrab=1;
for(j=strlen(s)-2;j>=0;j--){
day=day+(s[j]-'0')*mazrab;
mazrab*=10;
}
day+=20*mon;
day+=365*year;
finalyear=day/260;
day=day%260;
finaladad=day%13;
if(finaladad==0)finaladad=13;//else finaladad++;
// adadperyod=day;
strcpy(peryod,tzolkinname[day%20]);
cout<<finaladad<<" "<<peryod<<" "<<finalyear<<endl;
}
}
#include<string.h>
//#include<fstream.h>
#include<iostream.h>
void main(){
// ofstream cout("f:\\my300.out");
// ifstream cin("f:\\300.in");
char habmons[20][10]={
"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh",
"mac","kankin","muan","pax","koyab","cumhu","uayet"};
char tzolkinname[20][10]={"ahau","imix","ik","akbal","kan","chicchan","cimi","manik","lamat",
"muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac"};
long long i,n,year,k,j,day,finaladad,adadperyod,finalyear,mon,mazrab;
char peryod[10],s[10],habmon[10]
;
cin>>n;
cout<<n<<endl;
for(i=0;i<n;i++){
cin>>s;
cin>>habmon;
cin>>year;
for(k=0;k<20;k++)
if(strcmp(habmon,habmons[k])==0){
mon=k;
break;
}
day=mazrab=1;
for(j=strlen(s)-2;j>=0;j--){
day=day+(s[j]-'0')*mazrab;
mazrab*=10;
}
day+=20*mon;
day+=365*year;
finalyear=day/260;
day=day%260;
finaladad=day%13;
if(finaladad==0)finaladad=13;//else finaladad++;
// adadperyod=day;
strcpy(peryod,tzolkinname[day%20]);
cout<<finaladad<<" "<<peryod<<" "<<finalyear<<endl;
}
}
-
- Experienced poster
- Posts: 106
- Joined: Thu Jan 29, 2004 12:07 pm
- Location: Bangladesh
- Contact:
a previous post on this problem :
http://online-judge.uva.es/board/viewtopic.php?t=5131
another ( with a good debugging idea ) :
http://online-judge.uva.es/board/viewtopic.php?t=5989
hope it helps
http://online-judge.uva.es/board/viewtopic.php?t=5131
another ( with a good debugging idea ) :
http://online-judge.uva.es/board/viewtopic.php?t=5989
hope it helps
I didn't check thouroughly, but I solved it this week, so - what does this do?:
first day is 1, not 13, not sure if you are gettigng right answers for the sample input
why not just
Code: Select all
if(finaladad==0)finaladad=13;//else finaladad++;
why not just
Code: Select all
finaladad=(day%13)+1;
300- CE
I submitted the following code in OJ and got compiler error:
The above code compiles on vc++ and gives the correct answer. And in general, what is the source of CEs on OJ?
Code: Select all
Removed after ACC
Last edited by vijay03 on Wed Sep 20, 2006 12:41 pm, edited 1 time in total.
why WA?
I submitted it as C++ and it resulted in WA! As far i know, the logic is correct and gives the correct output for all the inputs i gave.. Do i need to change the code so that all the c functions are changed into c++? I thought c++ supported all the c functions..
There are errors in your lists of names.
For example, you have two "pop" (p[0] and p[15]), and some names are in a wrong order.
Also, instead of all this lengthy strcpy stuff, you can initilialize lists simply with:
For example, you have two "pop" (p[0] and p[15]), and some names are in a wrong order.
Also, instead of all this lengthy strcpy stuff, you can initilialize lists simply with:
Code: Select all
char p[19][10]={"pop","no","zip","zotz",.....};