2018.12.21 浪在ACM 集训队第十次测试赛

 浪在ACM 集训队第十次测试赛

 

A  Diverse Substring

B  Vasya and Books

C  Birthday

D  LCM

 

A 传送门

  题解

 

B 传送门

题解:  

  这道题,就比较简单了,直接用队列模拟一下就好了,话不多说,上代码:

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 using namespace std;
 5 #define mem(a,b) memset(a,b,sizeof(a))
 6 const int maxn=2e5+10;
 7 
 8 int n;
 9 int a[maxn];
10 bool inStack[maxn];//inStack[i]:判断数i是否再栈中
11 
12 int main()
13 {
14     scanf("%d",&n);
15     for(int i=1;i <= n;++i)
16         scanf("%d",a+i);
17     mem(inStack,true);
18     int index=1;
19     for(int i=1;i <= n;++i)
20     {
21         int b;
22         scanf("%d",&b);
23         if(!inStack[b] || index > n)//如果b不在栈中
24         {
25             printf("0\n");
26             continue;
27         }
28         
29         int res=0;
30         while(a[index] != b)
31         {
32             inStack[a[index++]]=false;
33             res++;
34         }
35         inStack[a[index++]]=false;
36         printf("%d\n",++res);
37     }
38     return 0;
39 }
View Code

题目来源:CodeForces - 1073B

 

C 传送门

题解:  

定义变量 tot 表示每个人拿 tot 个硬币
依据题意可得公式:
① : tot*M - K ≥ L
② : tot*M ≤ N
联利方程①②可得
(K+L)/M ≤ tot ≤ N/M
判断能否有满足条件的 tot
View Code

AC代码:

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 using namespace std;
 5 #define ll __int64
 6 
 7 ll N,M,K,L;
 8 
 9 ll Solve()
10 {
11     ll a=(K+L)/M+((K+L)%M == 0 ? 0:1);
12     ll b=N/M;
13     if(a > b)
14         return -1;
15     return a;
16 }
17 int main()
18 {
19     scanf("%I64d%I64d%I64d%I64d",&N,&M,&K,&L);
20     printf("%I64d\n",Solve());
21     return 0;
22 }
View Code

题目来源:CodeForces - 1068A 

 

D 传送门

  题解

posted @ 2018-12-23 10:12  HHHyacinth  阅读(144)  评论(0编辑  收藏  举报