CF1101A Minimum Integer 模拟
题意翻译
题意简述
给出qqq组询问,每组询问给出l,r,dl,r,dl,r,d,求一个最小的正整数xxx满足d∣x d | x\ d∣x 且x̸∈[l,r] x \not\in [l,r]x̸∈[l,r]
输入格式
第一行一个正整数q(1≤q≤500)q(1 \leq q \leq 500)q(1≤q≤500)
接下来qqq行每行三个正整数l,r,d(1≤l≤r≤109,1≤d≤109)l,r,d(1 \leq l \leq r \leq 10^9 , 1 \leq d \leq 10^9)l,r,d(1≤l≤r≤109,1≤d≤109)表示一组询问
输出格式
对于每一组询问输出一行表示答案
题目描述
You are given q q q queries in the following form:
Given three integers li l_i li , ri r_i ri and di d_i di , find minimum positive integer xi x_i xi such that it is divisible by di d_i di and it does not belong to the segment [li,ri] [l_i, r_i] [li,ri] .
Can you answer all the queries?
Recall that a number x x x belongs to segment [l,r] [l, r] [l,r] if l≤x≤r l \le x \le r l≤x≤r .
输入输出格式
输入格式:
The first line contains one integer q q q ( 1≤q≤500 1 \le q \le 500 1≤q≤500 ) — the number of queries.
Then q q q lines follow, each containing a query given in the format li l_i li ri r_i ri di d_i di ( 1≤li≤ri≤109 1 \le l_i \le r_i \le 10^9 1≤li≤ri≤109 , 1≤di≤109 1 \le d_i \le 10^9 1≤di≤109 ). li l_i li , ri r_i ri and di d_i di are integers.
输出格式:
For each query print one integer: the answer to this query.
输入输出样例
6
4
1
3
10
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 100005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
ll x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int q;
ll l, r, d; int main() {
ios::sync_with_stdio(0);
cin >> q;
while (q--) {
cin >> l >> r >> d;
ll L, R;
if (l%d != 0) {
L = (l / d);
}
else if (l%d == 0)L = l / d - 1;
if (r%d == 0)R = r / d + 1;
else if (r%d != 0)R = r / d + 1;
if (L == 0) {
cout << d * R << endl;
}
else {
cout << 1 * d << endl;
}
}
return 0;
}
CF1101A Minimum Integer 模拟的更多相关文章
- Minimum Integer CodeForces - 1101A (思维+公式)
You are given qq queries in the following form: Given three integers lili, riri and didi, find minim ...
- java模拟斗地主发牌看牌
import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; public class Dou ...
- Educational Codeforces Round 75 (Rated for Div. 2) C. Minimize The Integer
链接: https://codeforces.com/contest/1251/problem/C 题意: You are given a huge integer a consisting of n ...
- Codeforce 1251C. Minimize The Integer
C. Minimize The Integer time limit per test2 seconds memory limit per test256 megabytes inputstandar ...
- Educational Codeforces Round 58 (Rated for Div. 2)
A. Minimum Integer 水 #include<bits/stdc++.h> #define clr(a,b) memset(a,b,sizeof(a)) using name ...
- ACM-ICPC (10/15) Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2)
A. Search for Pretty Integers You are given two lists of non-zero digits. Let's call an integer pret ...
- Educational Codeforces Round 58 (Rated for Div. 2) 题解
Educational Codeforces Round 58 (Rated for Div. 2) 题目总链接:https://codeforces.com/contest/1101 A. Min ...
- Educational Codeforces Round 58 (Rated for Div. 2) (前两题题解)
感慨 这次比较昏迷最近算法有点飘,都在玩pygame...做出第一题让人hack了,第二题还昏迷想错了 A Minimum Integer(数学) 水题,上来就能做出来但是让人hack成了tle,所以 ...
- Codeforces Round #436 (Div. 2) 题解864A 864B 864C 864D 864E 864F
A. Fair Game time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
随机推荐
- mybatis 动态sql语句(1)
mybatis 的动态sql语句是基于OGNL表达式的.可以方便的在 sql 语句中实现某些逻辑. 总体说来mybatis 动态SQL 语句主要有以下几类: 1. if 语句 (简单的条件判断) 2. ...
- C# EntityFramwork(Model First)使用要点
本文介绍EntityFramework使用方法 Entity Framework的注意点 由于安装和操作的细节讲起来很琐碎,这部分只罗列出难点,其他细节请自行查阅 安装细节 Pluralize or ...
- VxVM vxsnap ERROR V-5-1-0 Volume cannot be linked due to size/regionsize incompatibility
在做vxsnap addmir时报错如下: #> vxsnap -g OLS_DATA_DG -b addmir OLS_DATA_ACC_P mirvol=OLS_DATA_ACC_SM1 V ...
- javascript——对象的基础知识
一.javascript作为脚本语言可以完成以下任务: 操纵浏览器对象,如窗口的打开与关闭: 操纵Dom树: 通过XMLHttpRequest对象与服务器端进行异步通信: XML编程,借助于Activ ...
- linux进程的软中断通信
linux进程的软中断通信 要求 实现软中断通信的程序 使用系统调用fork()创建两个子进程,再用系统调用signal()让父进程捕捉键盘上发出的中断信号(即按delete键),当父进程接收到这两个 ...
- 一段PHP异常
这是我写的一段代码,里面通过PHP异常功能,实现报错时显示出错代码所在行.当使用者操作出错时,截图给我,我可以很快得去追踪和排查错误! public function added_business_s ...
- C++对ASCII文件的操作例子
从键盘读入一行字符,把其中的字母字符依次放在磁盘文件f2.dat中,再把它从磁盘文件读入程序,将其中的小写字母改写成大写字母,再存入磁盘文件f3.dat. code: #include<iost ...
- Windows中lib和DLL区别和使用
本文转载自:http://www.cppblog.com/amazon/archive/2009/09/04/95318.html 共有两种库:一种是LIB包含了函数所在的DLL文件和文件中函数位置的 ...
- Arduino Serial库的使用
1 Serial.begin() 2 Serial.end() 3 Serial.available() 4 Serial.read() 5 Serial.peek() 6 Serial.flush( ...
- ZROI2018提高day3t3
传送门 分析 我们对于每一个可以匹配的字符都将其从栈中弹出,然后他的哈希值就是现在栈中的字符哈希一下.然后我们便可以求出对于哪些位置它们的哈希值是一样的,即它们的状态是一致的.而这些点可以求出它们的贡 ...