300 - Maya Calendar
Moderator: Board moderators
-
- New poster
- Posts: 24
- Joined: Mon Feb 24, 2003 5:08 pm
surprising
Mr. Pupirev,
This is the mystry. For your kind information I use Turbo C++ 3.0 compiler for coding and use online submatic 0.6 for submission.The first code , I got 2 times AC(PE) but your correction that is 2nd one I got only AC.Which one you use for coding and submission?
Try to explain it please.
This is the mystry. For your kind information I use Turbo C++ 3.0 compiler for coding and use online submatic 0.6 for submission.The first code , I got 2 times AC(PE) but your correction that is 2nd one I got only AC.Which one you use for coding and submission?
Try to explain it please.
300 - Maya Calendar
I am quiet frustrated !!!!!!! I got Run Time Error but can't find out what the flaw is. I would be very much glad if anyone comes forward to help me in finding that flaw.
my code has been deleted as I got AC
my code has been deleted as I got AC
Last edited by Ferdous on Sun Mar 07, 2004 9:42 am, edited 1 time in total.
I am destined to live on this cruel world........
-
- Experienced poster
- Posts: 106
- Joined: Thu Jan 29, 2004 12:07 pm
- Location: Bangladesh
- Contact:
-
- Experienced poster
- Posts: 106
- Joined: Thu Jan 29, 2004 12:07 pm
- Location: Bangladesh
- Contact:
I made changes in my code as Raiyan and sidky told. But it has ushered in new horizon of frustration !!!!!! This time it is awarded WA. This kind of situation really makes me averse to problem solving. I just can't understand what to do....... can't find any fault. Please extend to me your helping hands and for that I would be evergrateful.
Last edited by Ferdous on Sun Mar 07, 2004 9:44 am, edited 1 time in total.
I am destined to live on this cruel world........
-
- Experienced poster
- Posts: 106
- Joined: Thu Jan 29, 2004 12:07 pm
- Location: Bangladesh
- Contact:
Firstly, I recommend that you take the haab day input as long or unsigned long instead of string.
Secondly, try this : -
Secondly, try this : -
Code: Select all
total = h_year*365 + i*20 + h_day ; // dont add the 1 here
t_year = total/260;
current = total%260;
t_month = current%20;
if(!t_month) t_month = 20;
t_day = current%13 + 1; // add the 1 here
//if(!t_day) t_day = 13;
Raiyan, I made the following change but this time also it's awarded WA.
scanf("%lu %c %s %lu", &h_day, &a, h_month, &h_year); // a for '.'
instead of
scanf("%s %s %lu", a, h_month, &h_year); // a for haab day with '.'
I tried according to your second way of fixing mistake. But it gives wrong answer for 0. pop 0. So I changed my code according to your first way but.....WA. By the way, can anybody tell me whether my algorithm for solving this problem is right?
scanf("%lu %c %s %lu", &h_day, &a, h_month, &h_year); // a for '.'
instead of
scanf("%s %s %lu", a, h_month, &h_year); // a for haab day with '.'
I tried according to your second way of fixing mistake. But it gives wrong answer for 0. pop 0. So I changed my code according to your first way but.....WA. By the way, can anybody tell me whether my algorithm for solving this problem is right?
I am destined to live on this cruel world........
-
- Experienced poster
- Posts: 106
- Joined: Thu Jan 29, 2004 12:07 pm
- Location: Bangladesh
- Contact:
You can take the input like this :
hd=haab day;hm=haab month;hy=haab year;
I don't know wheather it'll make any differecnce or not.
This is what I did in the calculation part :
d=total days. total in your code.
ty=tzolkin year
td=tzolkin day( the period )
tm=tzolking name of the day.
The t_month can be 0, no need to make it 20 if it is 0. just print the 0th element from the array. Do same in all other cases, print the nth element , not the (n-1)th.
If you still get WA, then give me your email address and before doing that, make sure that there is no spelling mistakes in your tzolkin months and also chek their ordering.
Code: Select all
scanf("%ld. %s %ld",&hd,&hm,&hy);
I don't know wheather it'll make any differecnce or not.
This is what I did in the calculation part :
Code: Select all
d=hy*365 + i*20 + hd;
ty=d/260;
d=(d-ty*260);
td=d%13 + 1;
strcpy(tm,tzolkin[d%20]);
ty=tzolkin year
td=tzolkin day( the period )
tm=tzolking name of the day.
The t_month can be 0, no need to make it 20 if it is 0. just print the 0th element from the array. Do same in all other cases, print the nth element , not the (n-1)th.
If you still get WA, then give me your email address and before doing that, make sure that there is no spelling mistakes in your tzolkin months and also chek their ordering.
300 -> Invalid memory reference
I get runtime error:
The code:
I have no idea what this meansYour program has died with signal 11 (SIGSEGV). Meaning:
Invalid memory reference
Before crash, it ran during 0.000 seconds.

The code:
Code: Select all
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
using namespace std;
int get_month (char name [6],char haab_month [19][6]);
int main(int argc, char *argv[])
{
int haab_year = 0;
int tzolkin_year = 0;
int num_entries;
int current_month_haab;
char haab_month [19][6];
strcpy(haab_month[0], "pop");
strcpy(haab_month[1], "no");
strcpy(haab_month[2], "zip");
strcpy(haab_month[3], "zotz");
strcpy(haab_month[4], "tzec");
strcpy(haab_month[5], "xul");
strcpy(haab_month[6], "yoxkin");
strcpy(haab_month[7], "mol");
strcpy(haab_month[8], "chen");
strcpy(haab_month[9], "yax");
strcpy(haab_month[10], "zac");
strcpy(haab_month[11], "ceh");
strcpy(haab_month[12], "mac");
strcpy(haab_month[13], "kankin");
strcpy(haab_month[14], "muan");
strcpy(haab_month[15], "pax");
strcpy(haab_month[16], "koyab");
strcpy(haab_month[17], "cumhu");
strcpy(haab_month[18], "uayet");
char tzolkin_day [20][8];
int tzolkin_period_count = 13;
strcpy(tzolkin_day[0], "imix");
strcpy(tzolkin_day[1], "ik");
strcpy(tzolkin_day[2], "akbal");
strcpy(tzolkin_day[3], "kan");
strcpy(tzolkin_day[4], "chicchan");
strcpy(tzolkin_day[5], "cimi");
strcpy(tzolkin_day[6], "manik");
strcpy(tzolkin_day[7], "lamat");
strcpy(tzolkin_day[8], "muluk");
strcpy(tzolkin_day[9], "ok");
strcpy(tzolkin_day[10], "chuen");
strcpy(tzolkin_day[11], "eb");
strcpy(tzolkin_day[12], "ben");
strcpy(tzolkin_day[13], "ix");
strcpy(tzolkin_day[14], "mem");
strcpy(tzolkin_day[15], "cib");
strcpy(tzolkin_day[16], "caban");
strcpy(tzolkin_day[17], "eznab");
strcpy(tzolkin_day[18], "canac");
strcpy(tzolkin_day[19], "ahau");
int buff_first [20];
char buff_second [20][8];
int buff_third [20];
char a [3], b [6];
int c;
int announce;
int iks = 0;
scanf("%d", &announce);
while ( iks < announce )
{
scanf("%s", a);
scanf("%s", b);
scanf("%d", &c);
int haab_days;
haab_days = get_month (b,haab_month) * 20 + atoi(a) + (365 * c);
int tzolkin_first_conv = (haab_days + 1) % 13;
char tzolkin_char_conv [8];
strcpy(tzolkin_char_conv, tzolkin_day[(((haab_days + 1) % 20)-1)]);
int tzolkin_year_conv = (haab_days - tzolkin_first_conv) / 260;
if ( tzolkin_year_conv >= 1 ) { } else { tzolkin_year_conv = 0; }
buff_first[iks] = tzolkin_first_conv;
strcpy(buff_second[iks], tzolkin_char_conv);
buff_third[iks] = tzolkin_year_conv;
iks++;
}
for ( int pimp; pimp < iks; pimp++ )
{
printf("%d %s %d\n", buff_first[pimp], buff_second[pimp],
buff_third[pimp]);
}
return 0;
}
int get_month (char name [6],char haab_month [19][6])
{
int n = 0;
while ( 0 != strcmp( name, haab_month[n] ) )
{
n++;
}
return n;
}
-
- Experienced poster
- Posts: 106
- Joined: Thu Jan 29, 2004 12:07 pm
- Location: Bangladesh
- Contact:
You get this RTE if your program attempts to access any location out of bounds. May be some bug in your code causing the program to access beyond the array lmits you've declared or may be something like that. And also chek the spellings and the ordering of months. Spelling mistake can cause RTE in this problem. I know some people who got RTE because of wrong spelling of Haab or Tzolkin months.