## 10942 - Can of Beans

All about problems in Volume 109. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Raj Ariyan
Learning poster
Posts: 70
Joined: Sat Feb 05, 2005 9:38 am
Location: Gurukul
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
``````
Some Love Stories Live Forever ....

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:
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.
Ami ekhono shopno dekhi...
HomePage

mmij
New poster
Posts: 10
Joined: Mon Jul 11, 2005 7:13 am
Location: PlanetEarth
i used a 32bit int and got acc . So input will never exceed 32bit integer.

Niaz
Learning poster
Posts: 77
Joined: Fri Dec 17, 2004 11:06 am
Location: East West University, Dhaka, Bangladesh
Contact:
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
Please join The ACM Solver Group at Yahoo
http://groups.yahoo.com/group/acm_solver/

Niaz
Learning poster
Posts: 77
Joined: Fri Dec 17, 2004 11:06 am
Location: East West University, Dhaka, Bangladesh
Contact:
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
``````
Please join The ACM Solver Group at Yahoo
http://groups.yahoo.com/group/acm_solver/

Raj Ariyan
Learning poster
Posts: 70
Joined: Sat Feb 05, 2005 9:38 am
Location: Gurukul
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.
Some Love Stories Live Forever ....

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:
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
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

Niaz
Learning poster
Posts: 77
Joined: Fri Dec 17, 2004 11:06 am
Location: East West University, Dhaka, Bangladesh
Contact:
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.
Please join The ACM Solver Group at Yahoo
http://groups.yahoo.com/group/acm_solver/

Niaz
Learning poster
Posts: 77
Joined: Fri Dec 17, 2004 11:06 am
Location: East West University, Dhaka, Bangladesh
Contact:
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.
Please join The ACM Solver Group at Yahoo
http://groups.yahoo.com/group/acm_solver/

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong
How about this:

Input:

Code: Select all

``````2
0 0 1 2
0 0 0 2``````
Output:

Code: Select all

``````00 01 02
-1``````
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org