TEST 6
A. 比赛时间
- easy
1
2
3
4
5
6
7
8int d,h,m;
int main()
{
scanf("%d%d%d",&d,&h,&m);
d=((d-11)*24+h-11)*60+m-11;
if(d<0)printf("-1");
else printf("%d",d);
}
B. 可怕和弦
- 只要写个check函数就很好解决
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
46int sc[15],n,c;
int a[20005];
int vis[89];
int cd[15];
int ans[20005],num;
bool check(int x)
{
for(int i=1;i<=c;i++)
{
cd[i]=a[i+x-1];
}
sort(cd+1,cd+c+1);
int dx=cd[1]-sc[1];
for(int i=2;i<=c;i++)
{
if(cd[i]-sc[i]!=dx)return 0;
}
return 1;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
scanf("%d",&c);
for(int i=1;i<=c;i++)
{
scanf("%d",&sc[i]);
}
sort(sc+1,sc+c+1);
for(int i=1;i<=n-c+1;i++)
{
if(check(i))
{
ans[++num]=i;
}
}
printf("%d\n",num);
for(int i=1;i<=num;i++)
{
printf("%d\n",ans[i]);
}
return 0;
}
C. 逃离Lay博士
1 | int n, ans; |
D. 奶牛的延迟计划
1 | int main(){ |
E. 构造两个括号序列
- 正常的DP就好了
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16string str;
ll n, a[1005], dp[1005][1005], p = 2012;
int main(){
cin >> str;
n = str.size();
str = ' ' + str;
for (int i = 1; i <= n; i ++) a[i] = a[i - 1] + (str[i] == '(') * 2 - 1;
dp[0][0] = 1;
for (int i = 1; i <= n; i ++)
for (int j = 0; j <= a[i]; j ++)
if (str[i] == '(') {
if (j) dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % p;
else dp[i][j] = dp[i - 1][j];
} else dp[i][j] = (dp[i - 1][j + 1] + dp[i - 1][j]) % p;
cout << dp[n][a[n]];
}
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Ysmmm的快乐小屋!