标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2500 Accepted Submission(s): 518
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; char str[105]; int main() { while(gets(str)){ long long a,b; scanf("%lld%lld",&a,&b); getchar(); if(strcmp(str,"0")==0){ if(a<=0&&b>=0) printf("YES\n"); else printf("NO\n"); continue; } int len = strlen(str); if(len>11){ printf("NO\n"); continue; } int s = 0; bool flag = false,is_nag = false; if(str[0]==‘-‘) { s++; is_nag = true; } long long sum = 0; if(str[s]==‘0‘||!isdigit(str[s])) flag = true; for(int i=s;i<len&&!flag;i++){ if(isdigit(str[i])){ sum = sum*10 + str[i]-‘0‘; }else{ flag = true; } } if(flag){ printf("NO\n"); }else{ if(is_nag) sum = -sum; if(sum>=a&&sum<=b){ printf("YES\n"); }else{ printf("NO\n"); } } } return 0; }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5652826.html