Lösungsvorschlag

Nickname

Zeit

Testfälle

Score

ck

11:12:30

17 falsch

none

Bemerkungen:

Code


unsigned pmult(u,v,p) 
   unsigned u,v,p;
{
   unsigned long long x;

   x= u * v;
   return x % p; 
}

Generierter Assemblercode


	.file	"@22907.1.c"
gcc2_compiled.:
	.global __urem64
.section	".text"
	.align 4
	.global pmult
	.type	 pmult,#function
	.proc	016
pmult:
	!#PROLOGUE# 0
	save	%sp, -112, %sp
	!#PROLOGUE# 1
	smul	%i0, %i1, %o0
	mov	%o0, %o1
	mov	0, %o0
	mov	0, %o2
	call	__urem64, 0
	mov	%i2, %o3
	ret
	restore %g0, %o1, %o0
.LLfe1:
	.size	 pmult,.LLfe1-pmult
	.ident	"GCC: (GNU) 2.95.2 19991024 (release)"

Log

   pmult(  2147483642,   2147483640, p) =           35, result was           48
   pmult(  2147483640,            5, p) =   2147483612, result was   2147483608
   pmult(  2147483642,            7, p) =   2147483612, result was   2147483606
   pmult(  2147483646,   2147483646, p) =            1, result was            4
   pmult(  2147418111,   2147418111, p) =            2, result was       131073
   pmult(  1073741823,   1073741825, p) =    536870911, result was            1
   pmult(      131074,        65535, p) =            2, result was            0
   pmult(   249502872,   2134500193, p) =   1300542908, result was   1052548504
   pmult(   247604794,   1911154746, p) =   1015912211, result was    795556133
   pmult(   839565538,   1319405222, p) =    527842945, result was     12017293
   pmult(  2029666481,    563763802, p) =   1576361826, result was   1043527738
   pmult(   312990895,    815758529, p) =   1194939747, result was   1076044783
   pmult(  1067500453,   1834702790, p) =   1540862757, result was    628843679
   pmult(   673836957,   1915657757, p) =    179111136, result was   1725500105
   pmult(   571682762,    795619869, p) =   1733932789, result was   1522130403
   pmult(   289187556,     13043119, p) =    856643307, result was    854886877
   pmult(   884368456,   1866219066, p) =     72032870, result was   1450977361

   test(pmult)         : failed 17 of 20
   ticks(pmult) failed, because all results were incorrect.
   invalid, because the pmult() routine failed on too many test cases.