3月月赛签到题

你谷三月月赛T1(hack数据是真的毒瘤)

这里

据说是普及T1难度,事实上也是如此,但是多了一组毒瘤数据,long long爆了

由于时间关系我没写AC代码,这是uAC 100分代码,就因为那组毒瘤数据,但是不计分

贴代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<bits/stdc++.h>
#include<stdlib.h>
#define FR(x,k,z) for(register int x = k; x <= z; x++)
#define FFR(x,k,z) for(register int x = k; x < z; x++)
typedef long long int64;


using namespace std;

char nums[20999999];
int64 l, r;
int t;

int main()
{
cin >> l >> r >> t;
for (int i = 1; i <= t; i++)
{
scanf("%s", nums);
int64 act = 0;
int numlen = strlen(nums);
if (nums[0] == '0' && numlen != 1)//00这种不合法
{
cout << 1 << '\n';
continue;
}
if (nums[0] == '-' && nums[1] == '0')//有前导0不合法
{
cout << 1 << '\n';
continue;
}
if (nums[0] == '0' && numlen == 1)//有前导0不合法
{
cout << 0 << '\n';
continue;
}
if (nums[0] == '-' && numlen == 1)//单独一个'-'也不合法,注意这个坑点
{
cout << 1 << '\n';
continue;
}
if (numlen > 20)//long long范围最大为19位(复数为20),大于这个的直接判出去
{
cout << 2 << '\n';
continue;
}
if (nums[0] == '-')//分为非负数和负数数处理
{
for (int i = 1; i < numlen; i++)
{
act = act * 10 + (nums[i] - '0');
}
act *= -1;//记得要 * -1
if (act >= l)//负数只用比较最小端点
cout << 0 << '\n';
else
cout << 2 << '\n';
}
else
{
for (int i = 0; i < numlen; i++)
{
act = act * 10 + (nums[i] - '0');
}
if (act <= r)//正数只用比较最大端点
cout << 0 << '\n';
else
cout << 2 << '\n';
}
}
return 0;
}

这就是一个很简单的模拟,但是坑巨多(还有这个hack数据),细心就好了