跳到正文

题解

题解:P14257 嫉妒(jealousy)

JustChilling约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年3月13日
篇幅
约 1 分钟
题目
P14257

版本

  1. v1当前

思路

一道简单的模拟题,只需要依次计算出小 Y 每次到面试间门口的时间,再判断是否和小 S 面试开始或结束的时间重复,记录结构即可。

赛时代码

C++
#include<bits/stdc++.h>
using namespace std;
int ck(int ans,int y,int t){
    if(ans<y){
    	return 0;
	}
	if((ans-y)%t==0){
		return 1;
	}
	return 0;
}
int main(){
    int n,y,s,t;
    cin>>n>>y>>s>>t;
    int i;
    for(i=1;i<=n;++i){
        int x1=(i-1)*s,x2=i*s;
        if(ck(x1,y,t)==0&&ck(x2,y,t)==0){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}
原文