社区讨论

求 hack

P5238整数校验器参与者 1已保存回复 0

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
0 条
当前快照
1 份
快照标识符
@mjqlfj2x
此快照首次捕获于
2025/12/29 11:23
2 个月前
此快照最后确认于
2025/12/29 11:29
2 个月前
查看原帖
CPP
#include<bits/stdc++.h>
#define int long double
using namespace std;
// int read(){
// 	int x=0,f=1;
// 	char ch=getchar();
// 	while(!isdigit(ch)){
// 		if(ch=='-') f=-1;
// 		ch=getchar();
// 	}
// 	while(isdigit(ch)){
// 		x=(x<<1)+(x<<3)+(ch^48);
// 		ch=getchar();
// 	}
// 	return x*f;
// }
// void write(int x){
// 	if(x<0) putchar('-'),x=-x;
// 	if(x>9) write(x/10);
// 	putchar(x%10+'0');
// }
int l,r,t;
string a;
signed main(){
    // l=read();
    // r=read();
    // t=read();
    cin>>l>>r>>t;
    while(t--){
        cin>>a;
        int x=0,f=1,xx;
        for(int i=0;i<a.size();i++){
            if(a[i]=='-'){
                f=-1;
            }
            else{
                x*=10;
                x+=a[i]-'0';
            }
            // cout<<x<<"\n";
        }
        string b;
        xx=x;
        // cout<<xx<<"$$\n";
        while(xx){
            b=b+char(fmod(xx,10)+'0');
            xx=floor(xx/10);
            // cout<<xx<<"**\n";
            if(xx<1){
                break;
            }
        }
        reverse(b.begin(),b.end());
        if(f==-1&&x!=0){
            b="-"+b;
        }
        if(x==0){
            b="0";
        }
        // cout<<b<<" "<<a<<"=\n";
        if(b!=a){
            cout<<"1\n";
        }
        else{
            x*=f;
            if(l<=x&&x<=r){
                cout<<"0\n";
            }
            else{
                cout<<"2\n";
            }
        }
    }
    return 0;
}

回复

0 条回复,欢迎继续交流。

正在加载回复...