题意:给定函数: f(x) = θ(s1x - a1) + θ(s2x - a2) + ... + θ(snx - an), where si =  ± 1. Calculate its values for argument values x1, x2, ..., xm.其中      然后输入一系列si,ai,输出给定的f(xi)的值。

分析:之前一直没想到去化一化,其实就是分s=1和s=-1两种情况,然后分别算出θ(snx - an)==1有多少个,加起来就行了。Σ( ° △ °|||)︴

 #include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
using namespace std;
const int maxn=;
int up[maxn],down[maxn],x;
int main()
{
int n,m,s,a,cnt1=,cnt2=;
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%d%d",&s,&a);
if(s>) up[cnt1++]=a;
else down[cnt2++]=-a;
}
sort(up,up+cnt1);
sort(down,down+cnt2);
scanf("%d",&m);
for(int i=;i<=m;i++){
scanf("%d",&x);
int ans1=upper_bound(up,up+cnt1,x)-up;
int ans2=cnt2-(lower_bound(down,down+cnt2,x)-down);
printf("%d\n",ans1+ans2);
}
return ;
}

Gym 100187M-Heaviside Function的更多相关文章

  1. codeforces gym 100187M Heaviside Function

    //大概就是没想起来怎么做 解法:首先观察seitan方程,发现我们要找的是满足seitan(si*x-ai)=1的方程数,即si*x-ai>=0的方程数,因为si=1 or -1,于是分类讨论 ...

  2. CF Gym 100187M Heaviside Function(二分)

    题意:给你一个函数和一些系数,给你一堆询问,求函数值. 根据s的符号,分成两组讨论,函数值与比x小的系数数量有关,二分输出答案. #include<cstdio> #include< ...

  3. Codeforces Gym 100187M M. Heaviside Function two pointer

    M. Heaviside Function Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/ ...

  4. js 创建对象的方法

    <script> //1.字面量语法 var rectangle1 = {}; rectangle1.name="mindong"; rectangle1.width ...

  5. An Introduction to Measure Theory and Probability

    目录 Chapter 1 Measure spaces Chapter 2 Integration Chapter 3 Spaces of integrable functions Chapter 4 ...

  6. 通过百度echarts实现数据图表展示功能

    现在我们在工作中,在开发中都会或多或少的用到图表统计数据显示给用户.通过图表可以很直观的,直接的将数据呈现出来.这里我就介绍说一下利用百度开源的echarts图表技术实现的具体功能. 1.对于不太理解 ...

  7. 单位阶跃函数(Heaviside/unit step function)—— 化简分段函数

    注意,单位阶跃函数一种不连续函数. 1. 常见定义 最经典的定义来自于 Ramp function(斜坡函数,max{x,0})的微分形式: H(x)=ddxmax{x,0} 2. 化简分段函数 如对 ...

  8. Codeforce Gym 100015I Identity Checker 暴力

    Identity Checker 题目连接: http://codeforces.com/gym/100015/attachments Description You likely have seen ...

  9. Codeforces Gym 100610 Problem E. Explicit Formula 水题

    Problem E. Explicit Formula Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...

随机推荐

  1. 开发的时候,一定要及时控制CPU使用率以及使用内存大小等三个问题(一个星期检查一次)

    一直专注于功能的开发,没注意CPU和内存.昨天无意中发现两个问题: 1. 程序启动后,什么都没干,CPU就50%了(单核).现在想找原因降低使用率,感觉无从下手,要是平时就注意这个问题就好了. 2. ...

  2. 只看Delphi自带的WnAPI帮助似乎不够

    比如,MessageBox在Delphi自带帮助的参数说明中,对其第四个参数的MB_类型说明只有最常见的6种类型,这么多年搞得我天经地义的以为MessageBox就是这么简单.今天看了一位前辈写的老代 ...

  3. CodePen避免自动刷新导致的JS卡死

    经常需要做一些前端代码的实验, 这时候我往往会用JSFiddle或CodePen. 最近用CodePen更多一些, 里面提供的选项更加丰富, 提供了各种各样的HTML/Javascript/CSS P ...

  4. just so you're clear

    The Google Resume的第一句话是: Just so you're clear: it was not my idea to give a talk to Microsoft Resear ...

  5. 项目属性-->生成事件-->后期生成事件命令行

    以开源记牌器https://github.com/Epix37/Hearthstone-Deck-Tracker 为例,Hearthstone Deck Tracker项目中的后期生成事件命令行: i ...

  6. [ZOJ 3622] Magic Number

    Magic Number Time Limit: 2 Seconds      Memory Limit: 32768 KB A positive number y is called magic n ...

  7. HDOJ --- 2151 Worm

    Worm Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  8. 16位cpu下主引导扇区及用户程序的编写

    一些约定 主引导扇区代码(0面0道1扇区)加载至0x07c00处 用户程序头部代码需包含以下信息:程序总长度.程序入口.重定位表等信息 用户程序 当虚拟机启动时,在屏幕上显示以下两句话: This i ...

  9. HDOJ/HDU 1241 Oil Deposits(经典DFS)

    Problem Description The GeoSurvComp geologic survey company is responsible for detecting underground ...

  10. MFC如何获取编辑框中输入的内容

    1.GetDlgItemText() 2.先用 GetDlgItem(编辑框的ID)获取指向编辑框的指针.再用GetWindowText函数将获取内容保存至指定的字符数组里. 3.使用 GetDlgI ...