洛谷2019 3月月赛 T1

题干

2019第一次月赛 我只有255pts T1还是比较水的。。。 海星 T1一道简单的模拟(就是有坑。。导致很多人不能一次性AC 比如说我

_3个坑点

1.位数问题

2.-0

 

3.0...

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read () { LL res = 0 ;int f (1) ;char ch = getchar ();
    while (!isdigit(ch)) { if (ch == '-') f = -1 ;ch = getchar();}
    while (isdigit(ch)) res = (res << 1) + (res << 3) + (ch ^ 48) ,ch = getchar(); return res * f ;
}
LL l,r,t;
inline void print(__int128 x) {
    if(x<0) putchar('-'),x*=-1;
    if(x>9) print(x/10); putchar(x%10+48);
}
inline bool pd(string s) { __int128 x=0; register int f=0,tot=-1; register char ch=0;
    while(!isdigit(ch))f|=(ch=='-'),ch=s[++tot];
    while(tot<=s.length() and isdigit(ch)) {
        x=(x<<1)+(x<<3)+(ch^48); if(f) { if(x*-1>r or x*-1<l) return true;
        } else if(x>r or x<l) return true;
        ch=s[++tot];
    }
    return false;
}
signed main() {
    l=read(),r=read(),t=read();
    while(t--) {
        string s; getline(cin,s);
        bool flag1=0,flag2=0;
        if(s=="-") flag1=1;
        if(s[0]=='-' and s[1]=='0') flag1=1;
        if(s[0]=='0' and s.length()>1) flag1=1;
        if(flag1) { puts("1"); continue; } flag2=pd(s);
        if(flag2) { puts("2"); continue; }
        puts("0");
    }
    return 0;
}

 

不存在十全十美的文章 如同不存在彻头彻尾的绝望
原文地址:https://www.cnblogs.com/qf-breeze/p/10462535.html