203 字
1 分钟
题解:P14257 嫉妒(jealousy)
P14257 嫉妒(jealousy)题解
思路
对于某一场面试 ,如果想不被发现,必须同时满足:
- 开始时间不被发现: 对所有 。
- 结束时间不被发现: 对所有 。
由于小 Y 每隔 分钟出现一次,从 开始,所以小 S 会被小 Y 在第 分钟发现而且仅当 且 。
然后枚举每一场面试 ,只要有一场面试是合法的,那么就输出 Yes,否则输出 No。
时间复杂度为 。
Code
#include<bits/stdc++.h>using namespace std;#define int long longint n,y,s,t;bool check(int x) { if (x<y) return false; return (x-y)%t==0;}signed main() { ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>n>>y>>s>>t; for (int i=1;i<=n;i++) if (!check((i-1)*s) && !check(i*s)) { cout<<"Yes"; return 0; } cout<<"No"; return 0;}题解:P14257 嫉妒(jealousy)
https://banglee13.github.io/posts/p14257/分享文章
生成精美分享图或复制链接,与更多人分享本文。
继续阅读
最后更新于 ,距今已过 400 天
部分内容可能已过时