B. Dasha and friends
来源:互联网 发布:淘宝店优惠券怎么设置 编辑:程序博客网 时间:2024/06/06 19:15
解题说明:此题判断两个区间有没有交集,遍历判断。
#include<cstdio>#include<algorithm>#include<cstring>#include<cstdlib>#include<iostream>using namespace std;int main(){int n,k,h,c=0,i,j,p;scanf("%d%d",&n,&k);int x[101],y[101];for(i=0;i<n;i++){scanf("%d",&x[i]);}for(i=0;i<n;i++){scanf("%d",&y[i]);}for(i=0;i<n;i++){c=0;h=x[i]-y[0];for(j=0;j<n;j++){if(i+j<n){p=j;if(h==x[i+j]-y[j]){c++;}else{break;}}else{if(h==k+x[j-p-1]-y[j]){c++;}else{break;}}}if(c==n){printf("YES\n");return 0;}}printf("NO\n");return 0;}
0 0
- B. Dasha and friends
- B. Dasha and friends
- 761B Dasha and friends
- 【codeforces 761B】Dasha and friends
- Codeforces-Round 394#B-Dasha and friends
- CF761 B. Dasha and friends(水题)
- Codeforces 761B-Dasha and friends
- CodeForces 761B Dasha and friends
- Codeforces761B Dasha and friends
- 文章标题 coderforces 761B : Dasha and friends(KMP)
- Codeforces Round #394 (Div. 2)(A. Dasha and Stairs,B. Dasha and friends,C. Dasha and Password)
- Codeforces761B. Dasha and friends (KMP)
- Codeforces Round #394(Div. 2)B. Dasha and friends【思维+暴力】
- Codeforces Round #394 (Div. 2) B. Dasha and friends —— 暴力 or 最小表示法
- B. Friends and Presents
- Codeforces Round #394 (Div. 2)Dasha and friends
- codefoeces B. Friends and Presents
- 【CODEFORCES】 B. Friends and Presents
- xdoj 1191: 统计相似字符串
- ES6学习总结
- Xftp使用教程——问答方式
- 如何实现:两个int(32位)整数m和n的二进制表达中,有多少个位(bit)不同?
- spark-streaming-[3]-Transform
- B. Dasha and friends
- 进程环境
- [leetcode]566. Reshape the Matrix
- xdoj 1192: 锘爷考驾照
- 倒入包缺少R文件
- laravel中predis的应用
- CodeForces 732 A.Buy a Shovel(水~)
- jsp:include 之导入版权信息
- python使用mysql数据库