RT,貌似是在判断 long long 边界上出了问题,然而实在是没有调出来有什么毛病……
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
int t;
long long l, r;
bool judge1(string s) {
int len = s.size();
if(len != 1 && s[0] == '0') return 1;
if(len == 1 && s[0] == '-') return 1;
if(s[0] == '-' && s[1] == '0') return 1;
return 0;
}
int main() {
scanf("%lld%lld%d", &l, &r, &t);
while(t--) {
string s; cin >> s;
int len = s.size(), flag = 1; long long x = 0, f = 1;
if(judge1(s)) puts("1");
else {
if(s[0] == '-') f = -1;
for(int i = (s[0] == '-' ? 1 : 0); i < len; ++i) {
if(x > 922337203685477580 || (x == 922337203685477580 && ((f == 1 && s[i] > '7') || (f == -1 && s[i] > '8')))) {flag = 0; break;}
x = x * 10 + s[i] - '0';
}
x *= f;
if(!flag || (x < l || x > r)) puts("2");
else puts("0");
}
}
return 0;
}