H - Clock Pictures(kmp)

题意:给出两个表盘中各个指针与当前表盘正上方向的夹角。求出两个表盘是否是经过一定程度旋转的相同表盘。

思路:若是相同表盘,则指针的相对位置一定。即每个指针之间的差是相同的。故我们可以以某一表盘为标准,计算出相邻指针间的间隔距离,扩展到两倍,作为主串。另一表盘的指针间距作为匹配串使用kmp算法,看是否在主串中出现,若出现,则说明可以旋转某一角度使使两表盘重合。

代码如下:

#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cstdio>
#define INF 0x3f3f3f3f
#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for (auto i = a; i <= b; ++i)
#define bep(i, a, b) for (auto i = a; i >= b; --i)
#define lowbit(x) x &(-x)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
#define X1 first
#define Y1 second
#define IOS                      \
	ios::sync_with_stdio(false); \
	cin.tie(0
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值