HDU 5059 help him

Source: Internet
Author: User

Question: first judge whether the first is a negative number. If you remove the first symbol and determine whether the subsequent length is <= 12 and whether it is a number, then convert it into a number to see if it is in [a, B]. Pay attention to the-0 data.

If you do not judge whether the length is <= 12 and whether it is a number, convert it to a number to see if it is in [a, B].
# Include <cstdio> # include <cstring> char s [150], ss [150]; int A, B; long a, B; using namespace STD; int main () {While (gets (s )! = NULL )&&(~ Scanf ("% d", & B, & A) {A = A, B = B; gets (SS); int L = strlen (s ), flag = 1; if (L> 11 | L = 0) {puts ("no"); continue;} For (INT I = 1; I <L; I ++) if (s [I] <'0' | s [I]> '9') {puts ("no"); flag = 0; break ;} if (FLAG) {int flag1 = 1; long ans = 0; If (L = 1) {If (s [0] <'0' | s [0]> '9') {puts ("no"); continue ;} int now = s [0]-'0'; If (now> = B & now <= A) puts ("yes"); else puts ("no "); continue;} If (s [0] = '-') flag1 = 0; else if (s [0] <'0' | s [0]> '9') {puts ("n O "); continue;} If (flag1 & S [0] = '0') {puts (" no "); continue;} If (! Flag1 & S [1] = '0') {puts ("no"); continue;} If (flag1) for (INT I = 0; I <L; I ++) ans = ans * 10ll + s [I]-'0'; else {for (INT I = 1; I <L; I ++) ans = ans * 10ll + s [I]-'0'; ans =-ans;} If (ANS> = B & Ans <=) puts ("yes"); else puts ("no") ;}} return 0 ;}// pay attention to the single symbol and 0, and the problem of over int in computing

HDU 5059 help him

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.