1 条题解
-
1
汇编题解:
tr: .zero 12801280 n: .zero 8 m: .zero 8 a: .zero 800080 push_up(long long): push rbp mov rbp, rsp mov QWORD PTR [rbp-8], rdi mov rax, QWORD PTR [rbp-8] add rax, rax sal rax, 5 add rax, OFFSET FLAT:tr+24 mov rdx, QWORD PTR [rax] mov rax, QWORD PTR [rbp-8] add rax, rax or rax, 1 sal rax, 5 add rax, OFFSET FLAT:tr+24 mov rax, QWORD PTR [rax] add rdx, rax mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+24 mov QWORD PTR [rax], rdx nop pop rbp ret push_down(long long): push rbp mov rbp, rsp mov QWORD PTR [rbp-8], rdi mov rax, QWORD PTR [rbp-8] add rax, rax sal rax, 5 add rax, OFFSET FLAT:tr+24 mov rcx, QWORD PTR [rax] mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+16 mov rax, QWORD PTR [rax] mov rdx, QWORD PTR [rbp-8] add rdx, rdx sal rdx, 5 add rdx, OFFSET FLAT:tr+8 mov rsi, QWORD PTR [rdx] mov rdx, QWORD PTR [rbp-8] add rdx, rdx sal rdx, 5 add rdx, OFFSET FLAT:tr mov rdx, QWORD PTR [rdx] sub rsi, rdx lea rdx, [rsi+1] imul rax, rdx mov rdx, QWORD PTR [rbp-8] lea rsi, [rdx+rdx] lea rdx, [rcx+rax] mov rax, rsi sal rax, 5 add rax, OFFSET FLAT:tr+24 mov QWORD PTR [rax], rdx mov rax, QWORD PTR [rbp-8] add rax, rax or rax, 1 sal rax, 5 add rax, OFFSET FLAT:tr+24 mov rcx, QWORD PTR [rax] mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+16 mov rax, QWORD PTR [rax] mov rdx, QWORD PTR [rbp-8] add rdx, rdx or rdx, 1 sal rdx, 5 add rdx, OFFSET FLAT:tr+8 mov rsi, QWORD PTR [rdx] mov rdx, QWORD PTR [rbp-8] add rdx, rdx or rdx, 1 sal rdx, 5 add rdx, OFFSET FLAT:tr mov rdx, QWORD PTR [rdx] sub rsi, rdx lea rdx, [rsi+1] imul rax, rdx mov rdx, QWORD PTR [rbp-8] add rdx, rdx mov rsi, rdx or rsi, 1 lea rdx, [rcx+rax] mov rax, rsi sal rax, 5 add rax, OFFSET FLAT:tr+24 mov QWORD PTR [rax], rdx mov rax, QWORD PTR [rbp-8] add rax, rax sal rax, 5 add rax, OFFSET FLAT:tr+16 mov rdx, QWORD PTR [rax] mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+16 mov rax, QWORD PTR [rax] mov rcx, QWORD PTR [rbp-8] add rcx, rcx add rdx, rax mov rax, rcx sal rax, 5 add rax, OFFSET FLAT:tr+16 mov QWORD PTR [rax], rdx mov rax, QWORD PTR [rbp-8] add rax, rax or rax, 1 sal rax, 5 add rax, OFFSET FLAT:tr+16 mov rdx, QWORD PTR [rax] mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+16 mov rax, QWORD PTR [rax] mov rcx, QWORD PTR [rbp-8] add rcx, rcx or rcx, 1 add rdx, rax mov rax, rcx sal rax, 5 add rax, OFFSET FLAT:tr+16 mov QWORD PTR [rax], rdx mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+16 mov QWORD PTR [rax], 0 nop pop rbp ret build(long long, long long, long long): push rbp mov rbp, rsp sub rsp, 48 mov QWORD PTR [rbp-24], rdi mov QWORD PTR [rbp-32], rsi mov QWORD PTR [rbp-40], rdx mov rax, QWORD PTR [rbp-24] sal rax, 5 lea rdx, tr[rax] mov rax, QWORD PTR [rbp-32] mov QWORD PTR [rdx], rax mov rax, QWORD PTR [rbp-24] sal rax, 5 lea rdx, tr[rax+8] mov rax, QWORD PTR [rbp-40] mov QWORD PTR [rdx], rax mov rax, QWORD PTR [rbp-24] sal rax, 5 add rax, OFFSET FLAT:tr+24 mov QWORD PTR [rax], 0 mov rax, QWORD PTR [rbp-24] sal rax, 5 add rax, OFFSET FLAT:tr+24 mov rax, QWORD PTR [rax] mov rdx, QWORD PTR [rbp-24] sal rdx, 5 add rdx, OFFSET FLAT:tr+16 mov QWORD PTR [rdx], rax mov rax, QWORD PTR [rbp-32] cmp rax, QWORD PTR [rbp-40] jne .L4 mov rax, QWORD PTR [rbp-32] mov rax, QWORD PTR a[0+rax*8] mov rdx, QWORD PTR [rbp-24] sal rdx, 5 add rdx, OFFSET FLAT:tr+24 mov QWORD PTR [rdx], rax jmp .L3 .L4: mov rdx, QWORD PTR [rbp-32] mov rax, QWORD PTR [rbp-40] add rax, rdx sar rax mov QWORD PTR [rbp-8], rax mov rax, QWORD PTR [rbp-24] lea rcx, [rax+rax] mov rdx, QWORD PTR [rbp-8] mov rax, QWORD PTR [rbp-32] mov rsi, rax mov rdi, rcx call build(long long, long long, long long) mov rax, QWORD PTR [rbp-8] lea rsi, [rax+1] mov rax, QWORD PTR [rbp-24] add rax, rax or rax, 1 mov rcx, rax mov rax, QWORD PTR [rbp-40] mov rdx, rax mov rdi, rcx call build(long long, long long, long long) mov rax, QWORD PTR [rbp-24] mov rdi, rax call push_up(long long) .L3: leave ret add(long long, long long, long long, long long): push rbp mov rbp, rsp sub rsp, 32 mov QWORD PTR [rbp-8], rdi mov QWORD PTR [rbp-16], rsi mov QWORD PTR [rbp-24], rdx mov QWORD PTR [rbp-32], rcx mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr mov rax, QWORD PTR [rax] cmp QWORD PTR [rbp-24], rax jl .L12 mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+8 mov rax, QWORD PTR [rax] cmp QWORD PTR [rbp-16], rax jg .L12 mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr mov rax, QWORD PTR [rax] cmp QWORD PTR [rbp-16], rax jg .L10 mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+8 mov rax, QWORD PTR [rax] cmp QWORD PTR [rbp-24], rax jl .L10 mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+24 mov rdx, QWORD PTR [rax] mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+8 mov rcx, QWORD PTR [rax] mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr mov rax, QWORD PTR [rax] sub rcx, rax lea rax, [rcx+1] imul rax, QWORD PTR [rbp-32] add rdx, rax mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+24 mov QWORD PTR [rax], rdx mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+16 mov rdx, QWORD PTR [rax] mov rax, QWORD PTR [rbp-32] add rdx, rax mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+16 mov QWORD PTR [rax], rdx jmp .L6 .L10: mov rax, QWORD PTR [rbp-8] sal rax, 5 add rax, OFFSET FLAT:tr+16 mov rax, QWORD PTR [rax] test rax, rax je .L11 mov rax, QWORD PTR [rbp-8] mov rdi, rax call push_down(long long) .L11: mov rax, QWORD PTR [rbp-8] lea rdi, [rax+rax] mov rcx, QWORD PTR [rbp-32] mov rdx, QWORD PTR [rbp-24] mov rax, QWORD PTR [rbp-16] mov rsi, rax call add(long long, long long, long long, long long) mov rax, QWORD PTR [rbp-8] add rax, rax or rax, 1 mov rdi, rax mov rcx, QWORD PTR [rbp-32] mov rdx, QWORD PTR [rbp-24] mov rax, QWORD PTR [rbp-16] mov rsi, rax call add(long long, long long, long long, long long) mov rax, QWORD PTR [rbp-8] mov rdi, rax call push_up(long long) jmp .L6 .L12: nop .L6: leave ret calc(long long, long long, long long): push rbp mov rbp, rsp push rbx sub rsp, 40 mov QWORD PTR [rbp-24], rdi mov QWORD PTR [rbp-32], rsi mov QWORD PTR [rbp-40], rdx mov rax, QWORD PTR [rbp-24] sal rax, 5 add rax, OFFSET FLAT:tr mov rax, QWORD PTR [rax] cmp QWORD PTR [rbp-40], rax jl .L14 mov rax, QWORD PTR [rbp-24] sal rax, 5 add rax, OFFSET FLAT:tr+8 mov rax, QWORD PTR [rax] cmp QWORD PTR [rbp-32], rax jle .L15 .L14: mov eax, 0 jmp .L16 .L15: mov rax, QWORD PTR [rbp-24] sal rax, 5 add rax, OFFSET FLAT:tr mov rax, QWORD PTR [rax] cmp QWORD PTR [rbp-32], rax jg .L17 mov rax, QWORD PTR [rbp-24] sal rax, 5 add rax, OFFSET FLAT:tr+8 mov rax, QWORD PTR [rax] cmp QWORD PTR [rbp-40], rax jl .L17 mov rax, QWORD PTR [rbp-24] sal rax, 5 add rax, OFFSET FLAT:tr+24 mov rax, QWORD PTR [rax] jmp .L16 .L17: mov rax, QWORD PTR [rbp-24] mov rdi, rax call push_down(long long) mov rax, QWORD PTR [rbp-24] lea rcx, [rax+rax] mov rdx, QWORD PTR [rbp-40] mov rax, QWORD PTR [rbp-32] mov rsi, rax mov rdi, rcx call calc(long long, long long, long long) mov rbx, rax mov rax, QWORD PTR [rbp-24] add rax, rax or rax, 1 mov rcx, rax mov rdx, QWORD PTR [rbp-40] mov rax, QWORD PTR [rbp-32] mov rsi, rax mov rdi, rcx call calc(long long, long long, long long) add rax, rbx .L16: mov rbx, QWORD PTR [rbp-8] leave ret .LC0: .string "%d%d" main: push rbp mov rbp, rsp sub rsp, 48 mov edx, OFFSET FLAT:m mov esi, OFFSET FLAT:n mov edi, OFFSET FLAT:.LC0 mov eax, 0 call __isoc99_scanf mov QWORD PTR [rbp-8], 1 jmp .L19 .L20: mov rax, QWORD PTR [rbp-8] sal rax, 3 add rax, OFFSET FLAT:a mov rsi, rax mov edi, OFFSET FLAT:_ZSt3cin call std::basic_istream<char, std::char_traits<char> >::operator>>(long long&) add QWORD PTR [rbp-8], 1 .L19: mov rax, QWORD PTR n[rip] cmp QWORD PTR [rbp-8], rax jle .L20 mov rax, QWORD PTR n[rip] mov rdx, rax mov esi, 1 mov edi, 1 call build(long long, long long, long long) jmp .L21 .L24: lea rax, [rbp-16] mov rsi, rax mov edi, OFFSET FLAT:_ZSt3cin call std::basic_istream<char, std::char_traits<char> >::operator>>(long long&) mov rdx, rax lea rax, [rbp-24] mov rsi, rax mov rdi, rdx call std::basic_istream<char, std::char_traits<char> >::operator>>(long long&) mov rdx, rax lea rax, [rbp-32] mov rsi, rax mov rdi, rdx call std::basic_istream<char, std::char_traits<char> >::operator>>(long long&) mov rax, QWORD PTR [rbp-16] and eax, 1 test rax, rax je .L22 lea rax, [rbp-40] mov rsi, rax mov edi, OFFSET FLAT:_ZSt3cin call std::basic_istream<char, std::char_traits<char> >::operator>>(long long&) mov rcx, QWORD PTR [rbp-40] mov rdx, QWORD PTR [rbp-32] mov rax, QWORD PTR [rbp-24] mov rsi, rax mov edi, 1 call add(long long, long long, long long, long long) jmp .L21 .L22: mov rdx, QWORD PTR [rbp-32] mov rax, QWORD PTR [rbp-24] mov rsi, rax mov edi, 1 call calc(long long, long long, long long) mov rsi, rax mov edi, OFFSET FLAT:_ZSt4cout call std::basic_ostream<char, std::char_traits<char> >::operator<<(long long) mov esi, OFFSET FLAT:_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ mov rdi, rax call std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&)) .L21: mov rax, QWORD PTR m[rip] lea rdx, [rax-1] mov QWORD PTR m[rip], rdx test rax, rax setne al test al, al jne .L24 mov eax, 0 leave ret __static_initialization_and_destruction_0(int, int): push rbp mov rbp, rsp sub rsp, 16 mov DWORD PTR [rbp-4], edi mov DWORD PTR [rbp-8], esi cmp DWORD PTR [rbp-4], 1 jne .L28 cmp DWORD PTR [rbp-8], 65535 jne .L28 mov edi, OFFSET FLAT:_ZStL8__ioinit call std::ios_base::Init::Init() [complete object constructor] mov edx, OFFSET FLAT:__dso_handle mov esi, OFFSET FLAT:_ZStL8__ioinit mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev call __cxa_atexit .L28: nop leave ret _GLOBAL__sub_I_tr: push rbp mov rbp, rsp mov esi, 65535 mov edi, 1 call __static_initialization_and_destruction_0(int, int) pop rbp ret
信息
- ID
- 7
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 8
- 标签
- 递交数
- 31
- 已通过
- 7
- 上传者