Submission details
Task:Lukujono
Sender:NicholasAhman
Submission time:2025-11-19 21:10:45 +0200
Language:text
Status:READY
Result:45
Feedback
groupverdictscore
#1ACCEPTED45
Test results
testverdicttimescore
#1ACCEPTED0.00 s45details

Code

# --- 1. SETUP CONSTANTS ---
# O = 1
INCREASE O

# M = 512 ( Loop Limit )
# 512 iterations is enough because Odd steps now cover 2 sequence steps at once.
INCREASE M
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )
REPEAT M TIMES ( INCREASE M )

# F = 1 ( Run Flag )
CLEAR F
INCREASE F

# --- 2. MAIN LOOP ---
REPEAT M TIMES (

    # --- STEP A: PRINT CURRENT X ---
    REPEAT F TIMES (
        PRINT X
    )

    # --- STEP B: PING-PONG DIVISION ---
    # Calculate Q ( Quotient ) and R ( Remainder )
    # Cost: 3.5 ops per X ( Very Fast )
    REPEAT F TIMES (
        CLEAR Q
        CLEAR R
        CLEAR T
        
        REPEAT X TIMES (
            # T starts at 0. Set to 1.
            INCREASE T
            
            # If R=1: Pair found. Q++, R=0, T=0.
            REPEAT R TIMES (
                INCREASE Q
                CLEAR R
                CLEAR T
            )
            
            # If R=0: No pair. R=1, T=0.
            REPEAT T TIMES (
                INCREASE R
                CLEAR T
            )
        )

        # --- STEP C: STOP CHECK ---
        # If Q == 0 ( meaning X was 1 ), we stop.
        # Uses Z as inverter.
        
        CLEAR Z
        INCREASE Z
        REPEAT Q TIMES ( CLEAR Z )
        REPEAT Z TIMES ( CLEAR F )
        
        # --- STEP D: DOUBLE JUMP UPDATE ---
        # We branch based on R ( Odd/Even )
        
        REPEAT F TIMES (
            
            # Create Even Flag ( E )
            CLEAR E
            INCREASE E
            REPEAT R TIMES ( CLEAR E )
            
            # --- CASE 1: ODD ( R=1 ) ---
            # Sequence: X -> 3X+1 -> ( 3X+1 )/2
            # We PRINT the intermediate ( 3X+1 ) and SET X to ( 3X+1 )/2
            # This skips the expensive division of the large number.
            
            REPEAT R TIMES (
                CLEAR X
                CLEAR V
                
                # We have Q ( where X = 2Q + 1 )
                # Next X should be ( 3( 2Q+1 ) + 1 ) / 2 = ( 6Q + 4 ) / 2 = 3Q + 2
                # Intermediate V should be 6Q + 4
                
                # 1. Build New X ( 3Q + 2 )
                REPEAT Q TIMES (
                    INCREASE X
                    INCREASE X
                    INCREASE X
                )
                INCREASE X
                INCREASE X
                
                # 2. Build Intermediate V from New X
                # V = 2 * X. ( Since V / 2 = X )
                REPEAT X TIMES (
                    INCREASE V
                    INCREASE V
                )
                
                # 3. Print Intermediate
                PRINT V
                
                # X is already set to the next value ( 3Q + 2 ). Done.
            )
            
            # --- CASE 2: EVEN ( R=0 ) ---
            # Sequence: X -> X / 2
            # X is simply Q.
            
            REPEAT E TIMES (
                CLEAR X
                REPEAT Q TIMES ( INCREASE X )
            )
        )
    )
)

Test details

Test 1 (public)

Verdict: ACCEPTED

input
(empty)

correct output
(empty)

user output
# --- 1. SETUP CONSTANTS ---
# O = 1
INCREASE O

# M = 512 ( Loop Limit )
...

Feedback: 456 tests processed (command limit exceeded)