水题 Gym 100553K Knockout Racing
/*
题意:有若干个点在一个区间内来回移动,1m/s。
水题:n^2的复杂度能解决,注意时间可能大于一个周期,要取模
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std; typedef long long ll;
const int MAXN = 1e3 + ;
const int INF = 0x3f3f3f3f;
ll x[MAXN], y[MAXN];
struct Question
{
ll x, y, t;
}q[MAXN];
int ans[MAXN]; int main(void) //Gym 100553K Knockout Racing
{
// freopen ("K.in", "r", stdin);
freopen ("knockout.in", "r", stdin);
freopen ("knockout.out", "w", stdout); int n, m;
while (scanf ("%d%d", &n, &m) == )
{
for (int i=; i<=n; ++i) scanf ("%I64d%I64d", &x[i], &y[i]);
for (int i=; i<=m; ++i) scanf ("%I64d%I64d%I64d", &q[i].x, &q[i].y, &q[i].t);
for (int i=; i<=m; ++i)
{
int cnt = ;
for (int j=; j<=n; ++j)
{
ll d = q[i].t % ((y[j] - x[j]) * );
ll pos = x[j];
if (pos + d <= y[j]) pos += d;
else pos = y[j] - (d - (y[j] - x[j]));
if (q[i].x <= pos && pos <= q[i].y) cnt++;
}
ans[i] = cnt;
} for (int i=; i<=m; ++i) printf ("%d\n", ans[i]);
} return ;
}
水题 Gym 100553K Knockout Racing的更多相关文章
- Codeforces Gym 100531G Grave 水题
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...
- codeforces Gym 100187L L. Ministry of Truth 水题
L. Ministry of Truth Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...
- Codeforces Gym 100286G Giant Screen 水题
Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...
- UVaLive 6591 && Gym 100299L Bus (水题)
题意:略. 析:不解释,水题. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include < ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- 每日一刷(2018多校水题+2016icpc水题)
11.9 线段树 http://acm.hdu.edu.cn/showproblem.php?pid=6315 求逆序对个数 http://acm.hdu.edu.cn/showproblem.php ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
随机推荐
- Hexo搭建个人blog
Hexo搭建 现在只想说心累... 前几天看了几个牛人的blog,感觉他们的风格很舒服,然后就发现了Hexo这个好东西!激动的想马上自己也弄一个,昨天晚上开始看资料特别是:潘柏信写了两篇 HEXO搭建 ...
- 【转】PHP实现系统编程(四)--- 本地套接字(Unix Domain Socket)
原文:http://blog.csdn.net/zhang197093/article/details/78143687?locationNum=6&fps=1 --------------- ...
- 剑指Offer面试题43(Java版):n个骰子的点数
题目:把n个骰子仍在地上.全部骰子朝上一面的点数之和为s,输入n,打印出s的全部可能的值出现的概率. 解法一:基于递归求骰子的点数,时间效率不够高 如今我们考虑怎样统计每个点数出现的次数. 要向求出n ...
- Android 中间人攻击
0x00 Android中间人攻击的思路就是劫持局域网中被攻击机器和server间的对话.被攻击机器和server表面上工作正常,实际上已经被中间人劫持.能够从一张图来明确这个过程. 受攻击主机发送的 ...
- 最新Bootstrap手册
http://www.jqhtml.com/bootstraps-syntaxhigh/index.html
- 欧莱雅浅谈OC中方法调用的顺序中的Category
OC特有的分类Category,依赖于类.它可以在不改变原来的类内容的基础上,为类增加一些方法.分类的使用注意: (1)分类只能增加方法,不能增加成员变量: (2)在分类方法的实现中可以访问原来类中的 ...
- cgi fastcgi wsgi nginx python Dispatching TurboGears Python via FCGI
https://www.nginx.com/resources/wiki/start/topics/examples/simplepythonfcgi/ 117 2018-06-28 19:56:42 ...
- Fibonacci数的后9位
import java.math.*; import java.util.*; public class Main{ /** * @param args */ public static void m ...
- Struts2中怎样配置struts。xml?
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-/ ...
- 最好的6个Go语言Web框架
原文:Top 6 web frameworks for Go as of 2017 作者:Edward Marinescu 译者:roy 译者注:本文介绍截至目前(2017年)最好的6个Go语言Web ...