Another junk exam,this time failed a lot....
And today I read the ZOJ 7th Anniversary Contest problems via my SE W958C and code 3 of 7 problems.
Just now submitted the codes,one 1A,one forget to initialization,2A,the other forget to use Int64,2A...
Not in normal status...
Need a completely change....
Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts
Sunday, 1 March 2009
Saturday, 21 February 2009
Iron Chain Solved
I found that yesterday I forgot the theorem of kinetic energy when I was discussing this problem with CPY this morning.
Yeah,I just got an Accepted on this problem.I want to share my thoughts with all of you~~
I suppose you know that using the theorem of kinetic energy you can get the relation between velocity and displacement:
v=[2*g*x*(b-a+x)/(a+b)]^-1
P.S.:x is the displacement of one end of the iron chain.
So,we can suppose that the velocity in a VERY LITTILE displacement is increasing at a constant speed,then we can figure out the time the chain spent passing this VERY LITTLE displacement,then add the time the iron chain straightly falling down,and we will have some code like this bellow:

Then you can output the variable time as answer~
I am only a high school student in China,and I know my English isn't very well...
Hope this post useful to you,and hope you can understand my meaning..
HEHE~
Yeah,I just got an Accepted on this problem.I want to share my thoughts with all of you~~
I suppose you know that using the theorem of kinetic energy you can get the relation between velocity and displacement:
v=[2*g*x*(b-a+x)/(a+b)]^-1
P.S.:x is the displacement of one end of the iron chain.
So,we can suppose that the velocity in a VERY LITTILE displacement is increasing at a constant speed,then we can figure out the time the chain spent passing this VERY LITTLE displacement,then add the time the iron chain straightly falling down,and we will have some code like this bellow:

Then you can output the variable time as answer~
I am only a high school student in China,and I know my English isn't very well...
Hope this post useful to you,and hope you can understand my meaning..
HEHE~
Posted by
AquarHEAD
at
17:13:00
Tuesday, 27 January 2009
Corrected A Program From An Assembly Language Book
The code on the book Assembly Languuage Programming is like this:[without bold sentences]
TITLE EG617
STACKSG SEGMENT STACK 'STACK'
DW 32 DUP(0)
STACKSG ENDS
DATASG SEGMENT
CR EQU 13
LF EQU 10
CHARIN DB 'PLEASE INPUT A CHARACTER:','$'
CHAROUT DB 'THE RESULT IS:','$'
LOUT DB 'LETTER','$'
NOUT DB 'NUMBER','$'
OOUT DB 'OTHERS','$'
CRLF DB CR,LF,'$'
DATASG ENDS
CODESG SEGMENT
MAIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG
MOV AX,DATASG
MOV DS,AX
LEA DX,CHARIN
MOV AH,9
INT 21H
MOV AH,1
INT 21H
;MOV CL,AL
LEA DX,CRLF
MOV AH,9
INT 21H
LEA DX,CHAROUT
MOV AH,9
INT 21H
;MOV AL,CL
CMP AL,'0'
JB OTHERS
CMP AL,'9'
JA CON1
LEA DX,NOUT
MOV AH,9
INT 21H
JMP EXIT
CON1:
CMP AL,'A'
JB OTHERS
CMP AL,'Z'
JA CON2
LEA DX,LOUT
MOV AH,9
INT 21H
JMP EXIT
CON2:
CMP AL,'a'
JB OTHERS
CMP AL,'z'
JA OTHERS
LEA DX,LOUT
MOV AH,9
INT 21H
JMP EXIT
OTHERS:
LEA DX,OOUT
MOV AH,9
INT 21H
EXIT:
MOV AX,4C00H
INT 21H
MAIN ENDP
CODESG ENDS
END MAIN
Before I correct it,it always return the result from the proc OTHERS,so I add those two sentences into the code and it became correct.I think it may because the following code:
LEA DX,CRLF
MOV AH,9
INT 21H
LEA DX,CHAROUT
MOV AH,9
INT 21H
changed the value stored by the register AL,so I copyed it into the register CL,and it then became correct.
By the way,found that Assembly Language is very interesting and powerful~~
TITLE EG617
STACKSG SEGMENT STACK 'STACK'
DW 32 DUP(0)
STACKSG ENDS
DATASG SEGMENT
CR EQU 13
LF EQU 10
CHARIN DB 'PLEASE INPUT A CHARACTER:','$'
CHAROUT DB 'THE RESULT IS:','$'
LOUT DB 'LETTER','$'
NOUT DB 'NUMBER','$'
OOUT DB 'OTHERS','$'
CRLF DB CR,LF,'$'
DATASG ENDS
CODESG SEGMENT
MAIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG
MOV AX,DATASG
MOV DS,AX
LEA DX,CHARIN
MOV AH,9
INT 21H
MOV AH,1
INT 21H
;MOV CL,AL
LEA DX,CRLF
MOV AH,9
INT 21H
LEA DX,CHAROUT
MOV AH,9
INT 21H
;MOV AL,CL
CMP AL,'0'
JB OTHERS
CMP AL,'9'
JA CON1
LEA DX,NOUT
MOV AH,9
INT 21H
JMP EXIT
CON1:
CMP AL,'A'
JB OTHERS
CMP AL,'Z'
JA CON2
LEA DX,LOUT
MOV AH,9
INT 21H
JMP EXIT
CON2:
CMP AL,'a'
JB OTHERS
CMP AL,'z'
JA OTHERS
LEA DX,LOUT
MOV AH,9
INT 21H
JMP EXIT
OTHERS:
LEA DX,OOUT
MOV AH,9
INT 21H
EXIT:
MOV AX,4C00H
INT 21H
MAIN ENDP
CODESG ENDS
END MAIN
Before I correct it,it always return the result from the proc OTHERS,so I add those two sentences into the code and it became correct.I think it may because the following code:
LEA DX,CRLF
MOV AH,9
INT 21H
LEA DX,CHAROUT
MOV AH,9
INT 21H
changed the value stored by the register AL,so I copyed it into the register CL,and it then became correct.
By the way,found that Assembly Language is very interesting and powerful~~
Subscribe to:
Posts (Atom)