Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这个题不打表怎么做?我用汇编写还超时啊int main(void) { int k; for(;;) { scanf("%d", &k); if(k == 0) { break; } __asm { mov edi, dword ptr [k] mov ebx, edi shl edi, 1 _OLoop: mov ecx, edi mov eax, ebx xor edx, edx dec eax div ecx mov eax, edx _ILoop: mov edx, edi shr edx, 1 cmp eax, edx jge _2ndBranch _1stBranch: cmp ecx, edx je _Found inc ebx jmp _OLoop _2ndBranch: dec ecx dec eax _AfterBranches: add eax, ebx xor edx, edx div ecx mov eax, edx jmp _ILoop _Found: mov dword ptr [k], ebx } printf("%d\n", k); } } 汇编那段相当于 (ecx = n, ebx = m, eax = i, edi = k*2) int m, f = 0; for(m = k; f == 0; m++) { int n = k; int i; for(i = (m - 1) % n; ; i = (i + m) % n) { if(i < k >> 1) { if(n == k >> 1) { f = 1; } break; } else { n--; i--; } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator