Codeforces Round #299 (Div. 1) A. Tavas and Karafs 水题
Tavas and Karafs
Time Limit: 1 Sec Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/536/problem/A
Description
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs.
Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + (i - 1) × B.
For a given m, let's define an m-bite operation as decreasing the height of at most m distinct not eaten Karafses by 1. Karafs is considered as eaten when its height becomes zero.
Now SaDDas asks you n queries. In each query he gives you numbers l, t and m and you should find the largest number r such that l ≤ r and sequence sl, sl + 1, ..., sr can be eaten by performing m-bite no more than t times or print -1 if there is no such number r.
Input
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105).
Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1000000000.
Output
Sample Input
1 5 3
3 3 10
7 10 2
6 4 8
Sample Output
-1
8
-1
HINT
题意
给你一个等差数列,然后10e6次询问
题解:
傻逼题,只要每个数都小于等于t,前缀和小于等于t*m就好了
代码:
//qscqesze
#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>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
//const int inf=0x7fffffff; //无限大
const int inf=0x3f3f3f3f;
/* int buf[10];
inline void write(int i) {
int p = 0;if(i == 0) p++;
else while(i) {buf[p++] = i % 10;i /= 10;}
for(int j = p-1; j >=0; j--) putchar('0' + buf[j]);
printf("\n");
}
*/
//**************************************************************************************
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
ll A,B,q,t,m,l;
ll ans(ll x)
{
return A+(x-)*B;
}
ll sum(ll l,ll r)
{
ll x1=A+(l-)*B,x2=A+(r-)*B;
return 1ll*(x1+x2)*(r-l+)/;
}
int main()
{
scanf("%d%d%d",&A,&B,&q);
while(q--)
{
int l,t,m;
scanf("%d%d%d",&l,&t,&m);
int lef=l,rig=inf,mid;
while(lef<=rig)
{
mid=lef+rig>>;
if(ans(mid)<=t && sum(l,mid)<=1ll*t*m)lef=mid+;
else rig=mid-;
}
if(rig==l-)printf("-1\n");
else printf("%d\n",rig);
}
return ;
}
Codeforces Round #299 (Div. 1) A. Tavas and Karafs 水题的更多相关文章
- Codeforces Round #299 (Div. 2) B. Tavas and SaDDas 水题
B. Tavas and SaDDas Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/535/p ...
- Codeforces Round #299 (Div. 2) A. Tavas and Nafas 水题
A. Tavas and Nafas Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/535/pr ...
- 二分搜索 Codeforces Round #299 (Div. 2) C. Tavas and Karafs
题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http:/ ...
- 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas
题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...
- DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas
题目传送门 /* DFS:按照长度来DFS,最后排序 */ #include <cstdio> #include <algorithm> #include <cstrin ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #290 (Div. 2) A. Fox And Snake 水题
A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...
- Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
随机推荐
- Java八种基本类型
boolean 二进制位: true ,false byte 二进制位:8 -128 - 127 -2的7次方到2的7次方-1 char 二进制位:16 0 - 65535 short 二 ...
- Mysql存储之原生语句操作(pymysql)
Mysql存储之原生语句操作(pymysql) 关系型数据库是基于关系模型的数据库,而关系模型是通过二维表时实现的,于是构成了行列的表结构. 表可以看作是某个实体的集合,而实体之间存在联系,这个就需要 ...
- .NET 处理视频-MediaInfo 获取视频信息
获取视频信息的组件很多,本节介绍的是:MediaFile. 第一步.添加 MediaInfoDotNet 在项目上右键,选择“管理 NuGet 程序包”,浏览以选中 MediaInfoDotNet,然 ...
- 【并行计算】用MPI进行分布式内存编程(二)
通过上一篇中,知道了基本的MPI编写并行程序,最后的例子中,让使用0号进程做全局的求和的所有工作,而其他的进程却都不工作,这种方式也许是某种特定情况下的方案,但明显不是最好的方案.举个例子,如果我们让 ...
- How to insert a segment of noise to music file
如何向音频文件中插入噪声 为了研究噪声和音乐对EEG的的影响,实验前需要准备一段夹杂噪声的音乐. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ...
- 005zabbix3.0报错记录
一.问题描述 在zabbix_server添加变量时,出现了以下的报错,
- js弱数据类型的坑
1.从表单获取的value是字符串,如果需要为数字相加,则需要转换为number类型 <input type="number" id="val1"> ...
- FusionCharts 用法心得
现在主流的很多jQuery+js结合的图表展示插件,有HighCharts,ECharts等等,今天我们先来了解一下FusionCharts,也是一个非常不错的图表制作工具.希望我的同事以及其他需要帮 ...
- python模块之cx_Oracle
安装cx_Oracle wget http://download.oracle.com/otn/linux/instantclient/122010/instantclient-basic-linux ...
- beego学习笔记(4):开发文档阅读(6)
beego的响应流程: 1.监听的端口接收数据,默认是8080端口. 2.用户请求到达8080端口后,开始数据处理流程. 3.初始化CONTEXT对象.判断是否是WEBSOCKET请求,如果是,设置I ...