水题 Gym 100553K Knockout Racing

题目传送门

 1 /*
 2     题意:有若干个点在一个区间内来回移动,1m/s。
 3     水题:n^2的复杂度能解决,注意时间可能大于一个周期,要取模
 4 */
 5 #include <cstdio>
 6 #include <algorithm>
 7 #include <cstring>
 8 #include <cmath>
 9 using namespace std;
10
11 typedef long long ll;
12 const int MAXN = 1e3 + 10;
13 const int INF = 0x3f3f3f3f;
14 ll x[MAXN], y[MAXN];
15 struct Question
16 {
17     ll x, y, t;
18 }q[MAXN];
19 int ans[MAXN];
20
21 int main(void)        //Gym 100553K Knockout Racing
22 {
23 //    freopen ("K.in", "r", stdin);
24     freopen ("knockout.in", "r", stdin);
25     freopen ("knockout.out", "w", stdout);
26
27     int n, m;
28     while (scanf ("%d%d", &n, &m) == 2)
29     {
30         for (int i=1; i<=n; ++i)    scanf ("%I64d%I64d", &x[i], &y[i]);
31         for (int i=1; i<=m; ++i)    scanf ("%I64d%I64d%I64d", &q[i].x, &q[i].y, &q[i].t);
32         for (int i=1; i<=m; ++i)
33         {
34             int cnt = 0;
35             for (int j=1; j<=n; ++j)
36             {
37                 ll d = q[i].t % ((y[j] - x[j]) * 2);
38                 ll pos = x[j];
39                 if (pos + d <= y[j])    pos += d;
40                 else    pos = y[j] - (d - (y[j] - x[j]));
41                 if (q[i].x <= pos && pos <= q[i].y)    cnt++;
42             }
43             ans[i] = cnt;
44         }
45
46         for (int i=1; i<=m; ++i)    printf ("%d\n", ans[i]);
47     }
48
49     return 0;
50 }
时间: 2024-10-11 21:20:06

水题 Gym 100553K Knockout Racing的相关文章

codeforces Gym 100187L L. Ministry of Truth 水题

L. Ministry of Truth Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/K Description Andrey works in the Ministry of Truth. His work is changing articles in newspapers and magazines so that they praise the Party an

UVaLive 6591 &amp;&amp; Gym 100299L Bus (水题)

题意:略. 析:不解释,水题. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set>

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive

2015南阳CCPC L - Huatuo&#39;s Medicine 水题

L - Huatuo's Medicine Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Huatuo was a famous doctor. He use identical bottles to carry the medicine. There are different types of medicine. Huatuo put medicines into the bottles and chain these b

sdut 2841 Bit Problem (水题)

题目 贴这个题是因为看题解有更简单的方法, 我做的时候是直接算的, 也很简单. 贴一下题解吧: 如果一个整数不等于 0,那么该整数的二进制表示中至少有一位是 1. 这个题结果可以直接输出 x - (x&(x-1)); 因为x-1 之后二进制下,就是最右边的1变成了0, 最右边的1的 右边所有的0变成了1, 不影响最左边. 我的代码: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4

sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)

n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you will step into a distinctive battleground which is full of sweet and happiness. If you want to win the battle, you must do warm-up according to my inst

杭电(hdu)2053 Switch Game 水题

Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 13113    Accepted Submission(s): 7970 Problem Description There are many lamps in a line. All of them are off at first. A series of o

4.7-4.9补题+水题+高维前缀和

题目链接:51nod 1718 Cos的多项式  [数学] 题解: 2cosx=2cosx 2cos2x=(2cosx)^2-2 2cos3x=(2cosx)^3-3*(2cosx) 数归证明2cos(nx)能表示成关于2cosx的多项式,设为f(n) f(1)=x,f(2)=x^2-2(其中的x就是2cosx) 假设n=1~k时均成立(k>=3) 当n=k+1时 由cos((k+1)x)=cos(kx)cos(x)-sin(kx)sin(x) cos((k-1)x)=cos(kx)cos(x)

历年NOIP水题泛做

快noip了就乱做一下历年的noip题目咯.. noip2014 飞扬的小鸟 其实这道题并不是很难,但是就有点难搞 听说男神错了一个小时.. 就是$f_{i,j}$表示在第$i$个位置高度为$j$的时候最小点击次数 递推的话对于上升的情况只做一次,后面几次在后面再做.. #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> using namespace st