756 - Biorhythms

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

Moderator: Board moderators

UFP2161
A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm
Contact:

Post by UFP2161 »

The input file would look more like:
1

0 0 0 0
0 0 0 100
5 20 34 325
4 5 6 7
283 102 23 320
203 301 203 40
210 44 270 348
152 37 4 148
365 290 231 89
-1 -1 -1 -1
or it could be:
2

0 0 0 0
0 0 0 100
5 20 34 325
4 5 6 7
283 102 23 320
-1 -1 -1 -1

203 301 203 40
210 44 270 348
152 37 4 148
365 290 231 89
-1 -1 -1 -1
Read up on multiple input:
http://online-judge.uva.es/portal/modul ... ?id=minput
WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR »

Thanks a lot.

I've read about multiple input but obviously didn't quite
understand.

[/code]
WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

756 - Biorhythms

Post by WR »

Well, after a couple of days i tried again (multiple input taken into account?!), and still WA.

Is the format of my sample input/output correct?

input:
4

0 0 0 0
0 0 0 100
5 20 34 325
4 5 6 7
283 102 23 320
203 301 203 40
-1 -1 -1 -1

210 44 270 348
152 37 4 148
365 290 231 89
-1 -1 -1 -1

365 365 365 365
364 364 364 364
363 363 363 363
1 1 1 1
-1 -1 -1 -1

0 10 1 0
353 361 0 100
-1 -1 -1 -1
output:
Case 1: the next triple peak occurs in 21252 days.
Case 2: the next triple peak occurs in 21152 days.
Case 3: the next triple peak occurs in 19575 days.
Case 4: the next triple peak occurs in 16994 days.
Case 5: the next triple peak occurs in 8910 days.
Case 6: the next triple peak occurs in 10789 days.

Case 1: the next triple peak occurs in 20976 days.
Case 2: the next triple peak occurs in 21141 days.
Case 3: the next triple peak occurs in 21229 days.

Case 1: the next triple peak occurs in 21252 days.
Case 2: the next triple peak occurs in 21252 days.
Case 3: the next triple peak occurs in 21252 days.
Case 4: the next triple peak occurs in 21252 days.

Case 1: the next triple peak occurs in 17986 days.
Case 2: the next triple peak occurs in 989 days.
Thank you for having a look.

Added Jan., 30th
Having a look is fine, but I'd really appreciate an answer.
RustB
New poster
Posts: 16
Joined: Mon Jun 14, 2004 5:08 pm

Post by RustB »

[c] #include <stdio.h>
#include <fcntl.h>

int main(void)
{
char in[10];
int cas=1,x,t;
#ifndef ONLINE_JUDGE
close (0); open ("756.in", O_RDONLY);
close (1); open ("756.out", O_WRONLY | O_CREAT, 0600);
#endif
scanf("%d",&cas);
for(x=0;x<cas;x++)
{
gets(in);
t=0;
while(1)
{
long int n,p,e,i,d;
n=0;
scanf("%d %d %d %d",&p,&e,&i,&d);
if(p==-1 &&e==-1 && i==-1 && d==-1)
break;
t++;
n=p>e?p:e;
n=i>n?i:n;
n++;
while(1)
{
if((n-p)%23==0 && (n-e)%28==0 && (n-i)%33==0)
break;
n++;
}
printf("Case %d: the next triple peak occurs in %d days.\n",t,n-d);
}
printf("\n");
}
}
[/c]

Can anyone tell me why this is giving WA?

For this input:

Code: Select all

4

0 0 0 0
0 0 0 100
5 20 34 325
4 5 6 7
283 102 23 320
203 301 203 40
-1 -1 -1 -1

210 44 270 348
152 37 4 148
365 290 231 89
-1 -1 -1 -1

365 365 365 365 
364 364 364 364 
363 363 363 363 
1 1 1 1 
-1 -1 -1 -1 

0 10 1 0 
353 361 0 100 
-1 -1 -1 -1
I get this output:

Code: Select all

Case 1: the next triple peak occurs in 21252 days.
Case 2: the next triple peak occurs in 21152 days.
Case 3: the next triple peak occurs in 19575 days.
Case 4: the next triple peak occurs in 16994 days.
Case 5: the next triple peak occurs in 8910 days.
Case 6: the next triple peak occurs in 10789 days.

Case 1: the next triple peak occurs in 20976 days.
Case 2: the next triple peak occurs in 21141 days.
Case 3: the next triple peak occurs in 21229 days.

Case 1: the next triple peak occurs in 21252 days.
Case 2: the next triple peak occurs in 21252 days.
Case 3: the next triple peak occurs in 21252 days.
Case 4: the next triple peak occurs in 21252 days.

Case 1: the next triple peak occurs in 17986 days.
Case 2: the next triple peak occurs in 989 days.
My approach is brute force, but it definitely works quite fast... Is there some input for which this would fail? or is it a problem with the formatting?
neno_uci
Experienced poster
Posts: 104
Joined: Sat Jan 17, 2004 12:26 pm
Location: Cuba

756 WA

Post by neno_uci »

What is wrong with my code, I used a brute force algorithm to find the answer but it works very fast...

Code: Select all

Cut after AC
Please help me!!! :oops:
Last edited by neno_uci on Fri Apr 08, 2005 5:01 pm, edited 1 time in total.
neno_uci
Experienced poster
Posts: 104
Joined: Sat Jan 17, 2004 12:26 pm
Location: Cuba

Post by neno_uci »

I have solved this problem in a Chinese Online Judge, I don't know why I can't get AC here!!! :evil:
neno_uci
Experienced poster
Posts: 104
Joined: Sat Jan 17, 2004 12:26 pm
Location: Cuba

Post by neno_uci »

Any ideas??? :oops:
User avatar
dovier_antonio
New poster
Posts: 47
Joined: Fri Feb 18, 2005 5:00 am
Location: Havana, Cuba

Post by dovier_antonio »

I know you ???

Your team not is DJY Team UCI
neno_uci
Experienced poster
Posts: 104
Joined: Sat Jan 17, 2004 12:26 pm
Location: Cuba

Post by neno_uci »

Please Help!!! :oops:
neno_uci
Experienced poster
Posts: 104
Joined: Sat Jan 17, 2004 12:26 pm
Location: Cuba

Post by neno_uci »

I have solved it, i thought this was a multiple input problem, a lot of thanx to Adrian Kuegel. :D
WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR »

This problem used to have a blue flag but they obviously changed that.

How does the new input data structure look like?

Code: Select all

0 0 0 0
0 0 0 100
-1 -1 -1 -1
should be correct?!

If it is I don't know why I still receive a WA.

Could somebody please check the sample input/output (values were created at random, at least most of them)?

input:

Code: Select all

0 0 0 0
0 0 0 100
5 20 34 325
4 5 6 7
283 102 23 320
203 301 203 40
210 44 270 348
152 37 4 148
365 290 231 89
365 365 365 365
364 364 364 364
363 363 363 363
1 1 1 1
0 10 1 0
353 361 0 100
155 317 242 347
171 163 109 258
159 359 142 252
168 306 39 212
193 110 28 7
336 322 148 111
126 30 328 307
0 361 132 154
3 268 195 64
141 8 331 304
129 201 44 323
46 364 0 217
95 190 355 247
188 89 297 117
98 224 88 76
242 313 11 259
238 71 242 146
271 288 54 67
100 147 259 60
233 282 120 29
314 62 320 138
245 11 360 125
341 331 181 353
178 112 9 39
143 164 121 228
124 361 26 294
10 358 296 121
90 278 59 54
21 163 314 173
105 317 252 238
359 348 55 4
307 154 297 106
51 196 5 297
173 69 70 297
92 158 188 308
218 302 27 350
70 263 43 251
88 124 43 81
241 236 325 326
164 182 54 7
283 40 67 98
233 35 62 245
331 232 326 13
39 320 242 339
322 197 27 316
294 232 335 42
153 211 45 240
330 31 155 236
121 204 70 211
122 55 23 282
296 271 41 90
3 358 112 182
205 306 69 98
110 283 349 337
20 111 138 297
339 75 93 251
288 323 190 33
187 50 338 353
105 334 192 34
358 257 153 365
213 64 232 132
269 359 48 291
164 183 77 248
347 119 144 145
311 141 286 194
252 55 218 170
63 248 220 340
186 166 50 254
240 194 128 262
179 113 248 94
146 61 223 265
192 302 54 313
362 50 199 200
157 343 176 351
327 47 56 296
194 118 250 187
43 85 268 265
48 120 32 53
134 181 294 129
42 344 318 115
100 46 10 222
24 312 135 10
258 56 53 352
346 203 208 323
329 268 101 330
-1 -1 -1 -1
output:

Code: Select all

Case 1: the next triple peak occurs in 21252 days.
Case 2: the next triple peak occurs in 21152 days.
Case 3: the next triple peak occurs in 19575 days.
Case 4: the next triple peak occurs in 16994 days.
Case 5: the next triple peak occurs in 8910 days.
Case 6: the next triple peak occurs in 10789 days.
Case 7: the next triple peak occurs in 20976 days.
Case 8: the next triple peak occurs in 21141 days.
Case 9: the next triple peak occurs in 21229 days.
Case 10: the next triple peak occurs in 21252 days.
Case 11: the next triple peak occurs in 21252 days.
Case 12: the next triple peak occurs in 21252 days.
Case 13: the next triple peak occurs in 21252 days.
Case 14: the next triple peak occurs in 17986 days.
Case 15: the next triple peak occurs in 989 days.
Case 16: the next triple peak occurs in 4086 days.
Case 17: the next triple peak occurs in 17209 days.
Case 18: the next triple peak occurs in 14443 days.
Case 19: the next triple peak occurs in 17482 days.
Case 20: the next triple peak occurs in 14607 days.
Case 21: the next triple peak occurs in 2479 days.
Case 22: the next triple peak occurs in 1935 days.
Case 23: the next triple peak occurs in 20339 days.
Case 24: the next triple peak occurs in 9668 days.
Case 25: the next triple peak occurs in 5472 days.
Case 26: the next triple peak occurs in 14802 days.
Case 27: the next triple peak occurs in 21035 days.
Case 28: the next triple peak occurs in 4563 days.
Case 29: the next triple peak occurs in 9156 days.
Case 30: the next triple peak occurs in 19020 days.
Case 31: the next triple peak occurs in 3778 days.
Case 32: the next triple peak occurs in 19665 days.
Case 33: the next triple peak occurs in 8369 days.
Case 34: the next triple peak occurs in 11287 days.
Case 35: the next triple peak occurs in 8737 days.
Case 36: the next triple peak occurs in 7904 days.
Case 37: the next triple peak occurs in 4030 days.
Case 38: the next triple peak occurs in 10982 days.
Case 39: the next triple peak occurs in 20793 days.
Case 40: the next triple peak occurs in 19396 days.
Case 41: the next triple peak occurs in 18575 days.
Case 42: the next triple peak occurs in 10009 days.
Case 43: the next triple peak occurs in 14756 days.
Case 44: the next triple peak occurs in 2286 days.
Case 45: the next triple peak occurs in 16151 days.
Case 46: the next triple peak occurs in 2724 days.
Case 47: the next triple peak occurs in 12368 days.
Case 48: the next triple peak occurs in 12611 days.
Case 49: the next triple peak occurs in 3832 days.
Case 50: the next triple peak occurs in 12618 days.
Case 51: the next triple peak occurs in 8884 days.
Case 52: the next triple peak occurs in 6788 days.
Case 53: the next triple peak occurs in 14911 days.
Case 54: the next triple peak occurs in 14750 days.
Case 55: the next triple peak occurs in 11795 days.
Case 56: the next triple peak occurs in 530 days.
Case 57: the next triple peak occurs in 5922 days.
Case 58: the next triple peak occurs in 11335 days.
Case 59: the next triple peak occurs in 20561 days.
Case 60: the next triple peak occurs in 6377 days.
Case 61: the next triple peak occurs in 9038 days.
Case 62: the next triple peak occurs in 17163 days.
Case 63: the next triple peak occurs in 10743 days.
Case 64: the next triple peak occurs in 4809 days.
Case 65: the next triple peak occurs in 11225 days.
Case 66: the next triple peak occurs in 12557 days.
Case 67: the next triple peak occurs in 10424 days.
Case 68: the next triple peak occurs in 6340 days.
Case 69: the next triple peak occurs in 18426 days.
Case 70: the next triple peak occurs in 18882 days.
Case 71: the next triple peak occurs in 20236 days.
Case 72: the next triple peak occurs in 17482 days.
Case 73: the next triple peak occurs in 3813 days.
Case 74: the next triple peak occurs in 14216 days.
Case 75: the next triple peak occurs in 844 days.
Case 76: the next triple peak occurs in 1024 days.
Case 77: the next triple peak occurs in 14376 days.
Case 78: the next triple peak occurs in 13095 days.
Case 79: the next triple peak occurs in 21086 days.
Case 80: the next triple peak occurs in 2831 days.
Case 81: the next triple peak occurs in 5625 days.
Case 82: the next triple peak occurs in 804 days.
Case 83: the next triple peak occurs in 3888 days.
Case 84: the next triple peak occurs in 21184 days.
Case 85: the next triple peak occurs in 8503 days.
Case 86: the next triple peak occurs in 20880 days.
Case 87: the next triple peak occurs in 5813 days.
Case 88: the next triple peak occurs in 8810 days.
Case 89: the next triple peak occurs in 7580 days.
Case 90: the next triple peak occurs in 12267 days.
Case 91: the next triple peak occurs in 17487 days.
Case 92: the next triple peak occurs in 2676 days.
Case 93: the next triple peak occurs in 18855 days.
Case 94: the next triple peak occurs in 12540 days.
Case 95: the next triple peak occurs in 13865 days.
Case 96: the next triple peak occurs in 19060 days.
Case 97: the next triple peak occurs in 3326 days.
Case 98: the next triple peak occurs in 10624 days.
Case 99: the next triple peak occurs in 12788 days.
Case 100: the next triple peak occurs in 16766 days.
stubbscroll
Experienced poster
Posts: 151
Joined: Tue Nov 16, 2004 7:23 pm
Location: Norway
Contact:

Post by stubbscroll »

Your input format is correct and your output is correct.

Try this:

input:

Code: Select all

22 27 32 0
1 1 1 0
output:

Code: Select all

Case 1: the next triple peak occurs in 21251 days.
Case 2: the next triple peak occurs in 1 days.
I don't think there are any hard test cases (if you pass the example), except for boundary cases.
WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR »

Thanks a lot stubbscroll!

The last sample did the trick (there IS a difference between > and >= after all) - well, that and deleting one superfluous blank.

:D
dpitts
New poster
Posts: 31
Joined: Tue Jun 17, 2003 10:10 pm

I'm troubled too.

Post by dpitts »

Code: Select all

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
        int p, e, i;
        int d;
        int num = 0;
        while (cin >> p >> e >> i >> d) {
                if (p == e && e == i && i == d && d == -1)
                        break;
                p %= 23;
                e %= 28;
                i %= 33;
                while (p <= d) {
                        p += 23;
                }
                while (p != e || e != i) {
                        if (p < e || p < i)
                                p += 23;
                        if (e < p || e < i)
                                e += 28;
                        if (i < p || i < e)
                                i += 33;
                }
                cout << "Case " << ++num << ": the next triple peak occurs in " << p-d << " days." << endl;
        }
        return 0;
}
I have solved this problem in the past at other contests, using this algorithm. I can't figure out where the problem is, unless the jugde has a mistake.

Some help anyone?
mukeshtiwari
Learning poster
Posts: 63
Joined: Tue Mar 07, 2006 6:51 pm
Location: india

Post by mukeshtiwari »

getting WA . Plz help me . i used CRT to solve this problem . here is my code .

Code: Select all

#include<cstdio>
	int main()
		{

			int a,b,c,d,sum,m,w,i=1;
			while(scanf("%d%d%d%d",&a,&b,&c,&d)==4 && (a!=-1 || b!=-1 || c!=-1 || d!=-1))
			  {
				sum=0;
				a=a%23;
				b=b%28;
				c=c%33;
				m=21252;
				w=6;//precomputed for 23v+924w=1
				sum=sum+a*w*924;
				w=-9;//precomputed
				sum=sum+b*w*759;
				w=2;
				sum=sum+c*w*644;
				//printf("%d\n",sum);
				if((a==b)&&(b==c))
					sum=sum+21252;
				while(sum<=0)
					sum=sum+21252;
				printf("Case %d: the next triple peak occurs in %d days.\n",i++,sum-d);
			}
		}
[/code]
Post Reply

Return to “Volume 7 (700-799)”