Page 1 of 1
Posted: Sat Oct 15, 2005 3:56 pm
by Raj Ariyan
Hi Saif,
Here is the output for ur input. Hope it helps. Good Luck.
Code: Select all
-1
99 01 02
00 02 29
68 05 11
07 09 25
65 02 06
11 12 28
43 01 23
05 10 28
-1
96 07 23
39 05 10
10 12 13
65 08 14
69 04 09
58 08 12
42 02 11
36 03 14
05 07 15
49 03 29
06 11 30
02 10 15
22 01 24
41 11 30
01 09 14
24 06 25
83 10 19
16 08 23
13 10 31
87 06 09
73 02 07
74 10 21
37 06 17
75 03 11
51 04 09
31 04 17
38 11 28
84 09 11
59 01 05
-1
69 10 15
56 08 11
38 04 11
42 03 06
-1
04 09 22
85 03 15
-1
89 02 19
94 09 11
14 07 22
15 05 29
Posted: Sun Oct 16, 2005 12:48 am
by Jan
May be you considered the year as 32 bit int. But n<2^30. So you can take a year n*100+year(from input). It exceeds the limit of 32 bit. However i used 64 bit int.
Posted: Sun Oct 16, 2005 5:19 am
by mmij
i used a 32bit int and got acc

. So input will never exceed 32bit integer.
Posted: Sat Oct 22, 2005 4:55 pm
by Niaz
Raj Ariyan wrote:Hi Saif,
Here is the output for ur input. Hope it helps. Good Luck.
Code: Select all
-1
99 01 02
00 02 29
68 05 11
07 09 25
65 02 06
11 12 28
43 01 23
05 10 28
-1
96 07 23
39 05 10
10 12 13
65 08 14
69 04 09
58 08 12
42 02 11
36 03 14
05 07 15
49 03 29
06 11 30
02 10 15
22 01 24
41 11 30
01 09 14
24 06 25
83 10 19
16 08 23
13 10 31
87 06 09
73 02 07
74 10 21
37 06 17
75 03 11
51 04 09
31 04 17
38 11 28
84 09 11
59 01 05
-1
69 10 15
56 08 11
38 04 11
42 03 06
-1
04 09 22
85 03 15
-1
89 02 19
94 09 11
14 07 22
15 05 29
Hello Raj,
This outputs are not in order. Please check my outputs that I got according to Saif
Posted: Sat Oct 22, 2005 4:57 pm
by Niaz
Saif's Input
Code: Select all
52
1073741823 99 1 2
3 0 2 29
41 5 11 68
19169 7 9 25
26962 6 2 65
23281 12 11 28
2995 1 23 43
32391 10 28 5
292 9 31 83
19718 7 23 96
14771 5 10 39
25667 7 17 100
28703 10 13 12
17673 8 14 65
28253 9 4 69
32662 8 12 58
8723 11 2 42
12316 14 3 36
288 15 5 7
19264 29 3 49
15890 6 11 30
15006 15 10 2
19629 22 1 24
18756 30 11 41
13931 14 1 9
24626 25 6 24
16118 19 10 83
4833 23 8 16
22704 13 10 31
31673 9 6 87
26924 2 7 73
26777 21 10 74
23986 37 17 6
22355 75 3 11
4031 51 9 4
16941 31 17 4
31107 38 28 11
15457 84 9 11
14945 59 1 5
24221 47 6 0
27506 69 15 10
900 56 8 11
17410 38 4 11
21548 42 6 3
3602 37 31 2
9374 22 9 4
27348 85 15 3
8281 100 23 6
26418 89 19 2
18127 94 9 11
24648 22 14 7
14310 15 29 5
My Outputs...
Code: Select all
99 01 02
-1
68 05 11
07 09 25
65 02 06
11 12 28
43 01 23
05 10 28
-1
96 07 23
39 05 10
-1
10 12 13
65 08 14
69 04 09
58 08 12
42 02 11
36 03 14
05 07 15
49 03 29
06 11 30
02 10 15
22 01 24
41 11 30
01 09 14
24 06 25
83 10 19
16 08 23
13 10 31
87 06 09
73 02 07
74 10 21
37 06 17
75 03 11
51 04 09
31 04 17
38 11 28
84 09 11
59 01 05
-1
69 10 15
56 08 11
38 04 11
42 03 06
-1
04 09 22
85 03 15
-1
89 02 19
94 09 11
14 07 22
15 05 29
Posted: Tue Oct 25, 2005 11:39 am
by Raj Ariyan
Hi Niaz,
Ya, my second output is not correct here. Actually i used int64. Before submitting at uva i change it to long long. I'm just again check the code and replace long long to int64, now in shows the correct output which is -1. So, type casting may be the problem for giving the wrong output for 2nd case.
Posted: Tue Oct 25, 2005 11:52 am
by Dominik Michniewski
In fact you don't need int64 (or long long) in this problem.
First value, c, fits in long int range and you don't have to create full year.
Observe that when you calculate if year is leap or not, you can use following algorithm:
Y = c*100 + y
Y%4 is the same as y%4
Y%100 is the same as y
Y%400 is the same as c%4 if y == 0
Best regards
DM
Posted: Thu Nov 24, 2005 10:42 am
by Niaz
I am still getting wrong answer. All the outputs provided by Raj matched with mine. Please give me some tricky input so that I can fix my bug. Thanks in advance.
Posted: Tue Dec 20, 2005 5:43 pm
by Niaz
Please help me. This is such an easy problem and I am stucked there ! It is irritating. Plz give me some more input and output.
Posted: Tue Dec 20, 2005 6:08 pm
by Observer
How about this:
Input:
Output: