日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

CF1101A Minimum Integer 模拟

發(fā)布時(shí)間:2025/3/19 编程问答 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CF1101A Minimum Integer 模拟 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

題意翻譯

題意簡(jiǎn)述

給出qqq組詢(xún)問(wèn),每組詢(xún)問(wèn)給出l,r,dl,r,dl,r,d,求一個(gè)最小的正整數(shù)xxx滿(mǎn)足d∣x?d | x\ dx?且x?∈[l,r] x \not\in [l,r]x?[l,r]

輸入格式

第一行一個(gè)正整數(shù)q(1≤q≤500)q(1 \leq q \leq 500)q(1q500)

接下來(lái)qqq行每行三個(gè)正整數(shù)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(1lr109,1d109)表示一組詢(xún)問(wèn)

輸出格式

對(duì)于每一組詢(xún)問(wèn)輸出一行表示答案

題目描述

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 lxr .

輸入輸出格式

輸入格式:

The first line contains one integer q q q ( 1≤q≤500 1 \le q \le 500 1q500 ) — 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 1li?ri?109 , 1≤di≤109 1 \le d_i \le 10^9 1di?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.

輸入輸出樣例

輸入樣例#1: 復(fù)制 5 2 4 2 5 10 4 3 10 1 1 2 3 4 6 5 輸出樣例#1: 復(fù)制 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; }

?

轉(zhuǎn)載于:https://www.cnblogs.com/zxyqzy/p/10275693.html

總結(jié)

以上是生活随笔為你收集整理的CF1101A Minimum Integer 模拟的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。