回复:NOIP竞赛结束大家感觉如何
吃完饭后试了一下,不知道对题意有没理解错误-_-d
由于偶不熟悉C和PASCAL(爆),以下源码各位请54……
.386
.model flat,stdcall
option casemap:none
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
.DATA
szSignedFormat db "%d",0
szUnsignedFormat db "%u",0
.CODE
start:
push 4 ;Power
push 100 ;Base
call GetCycle
mov ebp,esp
push eax
push OFFSET szSignedFormat
push ebp
call wsprintf
add esp,12
mov ebp,esp
push 0
push ebp
push ebp
push 0
call MessageBox
push 0
call ExitProcess
GetCycle proc stdcall
mov eax,[esp + 4]
mov ebx,eax
mov ecx,[esp + 8]
dec ecx
sub esp,104
mov ebp,esp
and DWORD PTR[ebp + 100],0
@@:
xor edx,edx
mul ebx
jo Overflow
dec ecx
jnz @b
@@:
push eax
push eax
push OFFSET szUnsignedFormat
push ebp
call wsprintf
add esp,12
pop eax
xor ecx,ecx
@@:
inc ecx
mov bl,[esp + ecx]
test bl,bl
jz @f
mov [esp + ecx - 1],bl
jmp @b
@@:
dec ecx
cmp ecx,100
ja NotFound
xor esi,esi
inc esi
CompareStringStart:
mov edi,esi
CompareStringLoop:
xor ebp,ebp
@@:
mov bl,[esp + ebp]
add edi,ebp
cmp edi,ecx
je NotMatch
mov dl,[esp + edi]
sub edi,ebp
cmp bl,dl
jne NotMatch
inc ebp
cmp ebp,esi
jne @b
add edi,esi
cmp edi,ecx
jb CompareStringLoop
FullyMatched:
mov [esp + 100],esi
NotMatch:
inc esi
mov edx,ecx
shr edx,1
cmp esi,edx
jbe CompareStringStart
cmp DWORD PTR[esp + 100],0
je NotFound
xor edx,edx
mov eax,ecx
mov ecx,[esp + 100]
div ecx
EndOfProc:
add esp,104
ret 8
Overflow:
NotFound:
xor eax,eax
dec eax
jmp EndOfProc
GetCycle endp
end start
编译选项:
ml /c /coff /nologo GetCycle.asm
link /subsystem:windows /libpath:\masm32\lib /nologo GetCycle.obj
很懒就没有做参数录入了,不知道比赛的话这样会不会扣分?
另外精度是个问题……完整的应该要采用浮点寄存器Orz