naco3是什么| 肚子胀气老放屁是什么原因| 附属医院是什么意思| 血钾高是什么引起的| 坐车头疼是什么原因| 脱氧核糖是什么| 为什么不建议吃大豆油| 铁锈红配什么颜色好看| 蚜虫用什么药| 休是什么意思| 鱼腥味是什么妇科病| 用什么方法治牙疼| 胆红素阴性是什么意思| 大便颗粒状是什么原因| 为什么会口臭| 什么的梦想| 碧字五行属什么| 颞颌关节炎吃什么药| 腰椎间盘突出吃什么药好| 逆商是什么| 无什么为什么| 孤臣是什么意思| 桂林山水甲天下是什么意思| 姬松茸和什么煲汤最佳| 肠鸣是什么原因引起的| 月忌日是什么意思| 半夜是什么时辰| 西瓜能做什么美食| 什么鲸鱼最大| 干呕是什么原因| 颜值控是什么意思| 梅花在什么季节开放| 颠了是什么意思| o型血为什么叫熊猫血| 异食癖是什么意思| 什么钻进风箱里两头受气| 55年属什么| dennis什么意思| 葛根粉有什么功效| 做肠镜前一天可以吃什么| 一鸣惊人指什么生肖| 来事头疼什么原因| 牙齿浮起来是什么原因| 湿气太重吃什么排湿最快| 近视什么意思| 香蕉补什么| 怀女儿有什么症状| 梦到丢了一只鞋是什么意思| 宵夜吃什么| 梦见吃药是什么意思| 国药准字h代表什么| 菠菜什么季节吃| 猫咪睡姿代表什么图解| 嗜睡是什么病的前兆| 自由基是什么意思| 抬头纹开了是什么意思| 阳虚吃什么好| 什么样的人不适合吃人参| 6月28日什么星座| 右眉上方有痣代表什么| 1987年什么命| 狗皮肤病用什么药| 哈伦裤配什么上衣| aape是什么牌子| 母慈子孝下一句是什么| 发烧应该挂什么科| 灰棕色是什么颜色| 习俗是什么意思| 盆腔炎做什么检查能查出来| 公鸡的尾巴像什么| 有缘无分是什么意思| 怀孕前有什么征兆| 扑街是什么意思| pnh是什么病的简称| 被紫外线灯照到有什么后果呀| 试孕纸什么时候测最准| 出cos是什么意思| mua是什么意思| 50年属什么生肖| 面部神经吃什么药| 梦到跟人吵架是什么意思| 手指月牙白代表什么| 口腔溃疡是什么原因| 什么是吸附性义齿| 喉咙发炎吃什么食物| 人的牙齿为什么不能再生| 蒸鱼豉油什么时候放| 喝咖啡有什么好处| 头位是什么意思| 开什么店好赚钱| mansory是什么车| 玫瑰糠疹吃什么药| 笃行是什么意思| 双侧胸膜增厚是什么意思| 胆碱酯酶是什么意思| 少尉军衔是什么级别| 什么袍加身| 凤凰长什么样| 全科门诊主要看什么| 喉咙痛买什么药| 行长是什么级别| 梦见两只狗是什么征兆| 胃经常胀气是什么原因| 幽门螺旋杆菌有什么症状| 腹泻能吃什么水果| 淀粉酶高有什么危害| 查胃病做什么检查合适| 身在其位必谋其职是什么意思| 什么是外阴炎| 呸是什么意思| 抗结剂是什么| 热感冒流鼻涕吃什么药| 满目苍夷是什么意思| hpv81低危型阳性是什么意思| 月经量多是什么原因引起的| 死了妻子的男人叫什么| 胸疼应该挂什么科| 梦见铲雪预示着什么| 钙化是什么意思啊| 脾阴虚吃什么中成药| 属羊的和什么属相不合| 舌苔厚黄是怎么回事吃什么药| 钩针ch是什么意思| 葡萄糖属于什么糖| 冢字的意思是什么| 名什么中外| lge是什么意思| 牙龈痛什么原因| 粉尘螨过敏是什么意思| 芹菜榨汁有什么功效| 红玛瑙五行属什么| 打鸟是什么意思| 头上汗多是什么原因| 乳腺钙化是什么意思啊| 世界上最小的花是什么花| 可塑性是什么意思| 水痘擦什么药膏好得快| 今年66岁属什么生肖的| 左腿发麻是什么原因| 什么都没有| 复辟什么意思| 手肘黑是什么原因| 雾化主要治疗什么| 心脏不好的人吃什么好| 子宫内膜息肉有什么症状| 感冒吃什么| 血红蛋白偏低的原因和危害是什么| 霉菌反复发作是什么原因| 五六天不拉大便是什么原因| 自律性是什么意思| 中午吃什么饭| 天然气主要成分是什么| 甲抗是什么原因引起的| phicomm是什么牌子| 能吃是福是什么意思| bbw女孩是什么意思| 血小板减少是什么原因| 胃功能四项检查是什么| 小孩急性肠胃炎吃什么药| 睡前喝蜂蜜水有什么好处| 阴道炎用什么洗液| 什么叫易经| 粘膜慢性炎是什么病| 丙肝阳性是什么意思呢| 拔完智齿可以吃什么| 通情达理是什么意思| 急性胃炎吃什么食物好| 打喷嚏代表什么| 全身骨显像是查什么的| 猪肚是什么器官| 什么是阑尾炎| 酸西地那非片是什么药| 无痛人流和普通人流有什么区别| 狐假虎威什么意思| 脚上长水泡是什么原因引起的| 吃什么对血管好| 梦见自己准备结婚是什么意思| 长卿是什么意思| 儿童头疼吃什么药| 内讧是什么意思| 共工是什么神| 小分子肽能治什么病| bcr是什么意思| 西米是用什么做的| 空调抽湿是什么意思| 天丝是什么材质| 高铁动力来源是什么| 痣发痒是什么原因| PA医学上是什么意思| 鼻血止不住是什么原因| 中耳炎什么症状| 草果在炖肉起什么作用| 名声大噪是什么意思| 一只眼睛肿了是什么原因| 早搏吃什么药最管用| 姓薄的读音是什么| 8月20号什么星座| 业已毕业是什么意思| 哥哥的老婆叫什么| 坐怀不乱柳下惠什么意思| 经常射精有什么伤害| 谷草谷丙偏高是什么原因| gpi是什么意思| 膀胱过度活动症是什么原因引起的| 槟榔中间的膏是什么| 燕窝有什么好处| 肚子怕冷是什么原因该怎么办| 脾切除后有什么影响和后遗症| 四不念什么| 鼻屎多是什么原因| 坐久了脚肿是什么原因| 皮下是什么意思| 气血不足看什么科室| 脾胃伏火是什么意思| 鹅口疮是什么| 甲醛中毒有什么症状| 鸡眼用什么药好| 古代天花是现代什么病| 男人下面出汗是什么原因| 心电图窦性心动过速是什么意思| 12月是什么星座的| ahc是韩国什么档次| 吃什么最容易减肥| 四妙丸有什么功效与作用| 哈西奈德溶液治什么病| 血镁偏高是什么原因| rush是什么东西| 喝酒不能吃什么药| 自然周是什么意思| 今天中国什么节日| 小沈阳名字叫什么| 征候是什么意思| who是什么意思| 尿蛋白弱阳性什么意思| 扩容是什么意思| hm平方是什么单位| 荔枝晒干了叫什么| 咽炎吃什么药好使| 刑冲破害是什么意思| 什么是低钾血症| 五心烦热吃什么中成药| 绝育是什么意思| 净身是什么意思| 为什么糙米越吃血糖越高| 三级综合医院是什么意思| vps是什么| 湉是什么意思| 有利有弊是什么意思| 弯了是什么意思| 免疫力低吃什么好| 高血压头晕吃什么药| 什么发什么颜| 舌苔厚腻发白是什么原因| 脚底板发热是什么原因| 人大常委会主任是什么级别| 胶体金法是什么意思| 什么奶茶最好喝| 大肠在人体什么位置图| 产妇能吃什么水果| 苹果5s什么时候上市的| 梦到吃饭是什么意思| 金达莱是什么花| 什么叫修辞手法| 磨砂皮是什么皮| 百度

小肚右边疼是什么原因

百度   当天,被称为中国经济领域双百榜的共和国60年经济盛典系列评选共揭幕了共和国60年影响中国经济60人、共和国60年最具影响力品牌60强及2009年度人民社会责任奖等9个奖项。


AtCoder Beginner Contest 417

A A Substring

You are given an N-character string S consisting of lowercase English letters.
Output the string of N?A?B characters obtained by removing the first A characters and the last B characters from S.

翻译:

给定一个由 N 个小写英文字母组成的字符串 S。
输出 S 字符串移除前 A个字符,后 B 个字符后的字符串。

分析:使用string中的 s.erase(pos, k) 删除 s中的从 pos 下标开始的连续 k个元素。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 10, inf = 0x3f3f3f3f;

void solve() {
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;
    s.erase(0, a);
    s.erase(s.size()-b, b); 
    cout << s;
}

int main() {
    int T = 1; while (T--) solve();
    return 0;
}

B Search and Delete

Takahashi has an integer sequence A = ( A 1 , A 2 , … , A N ) A=(A_1,A_2,…,A_N) A=(A1?,A2?,,AN?) of length N.
It is guaranteed that A is non-decreasing.

Takahashi performs M operations on this integer sequence.
In the i-th operation ( 1 ≤ i ≤ M ) (1\le i\le M) (1iM), he performs the following operation:

If the sequence A contains B i B_i Bi? as an element, select one such element and delete it. If no such element exists, do nothing.
Note that since A is non-decreasing, the sequence after the operation is uniquely determined regardless of the choice of element, and remains non-decreasing.

Find A after performing M operations.

翻译:

高桥有一个长度为 N 的整数序列 A = ( A 1 , A 2 , … , A N ) A=(A_1,A_2,…,A_N) A=(A1?,A2?,,AN?)
保证 A 是非递减的。

高桥对这个整数序列执行 M 次操作。在第 i ( 1 ≤ i ≤ M ) (1\le i\le M) (1iM) 次操作中,他执行以下操作:

如果序列 A 包含 B i B_i Bi? 作为元素,选择其中一个这样的元素并删除它。如果不存在这样的元素,则不执行任何操作。
注意,由于 A 是非递减的,操作后的序列无论选择哪个元素都是唯一确定的,并且仍然保持非递减。

执行 M 次操作后找到 A 。

分析:数据范围很小,直接暴力模拟即可。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 10, inf = 0x3f3f3f3f;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n + 1), b(m + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) cin >> b[i];

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (b[i] == a[j]) {
                a[j] = -1;
                break;
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        if (a[i] != -1)
            cout << a[i] << ' ';
    }
}

int main() {
    int T = 1; while (T--) solve();
    return 0;
}

C Distance Indicators

You are given an integer sequence A = ( A 1 , A 2 , . . . A N ) A=(A_1,A_2,...A_N) A=(A1?,A2?,...AN?) of length N.

Find how many pairs of integers (i,j) ( 1 ≤ i < j ≤ N 1\le i<j \le N 1i<jN) satisfy j ? i = A i ? A j j-i=A_i-A_j j?i=Ai??Aj?.

Constraints: 1 ≤ N ≤ 2 × 1 0 5 , 1 ≤ A i ≤ 2 × 1 0 5 ( 1 ≤ i ≤ N ) 1\le N\le 2\times 10^5,1 \le A_i \le 2\times 10^5(1\le i\le N) 1N2×105,1Ai?2×105(1iN)

翻译:

你被给定一个长度为 N 的整数序列 A = ( A 1 , A 2 , . . . A N ) A=(A_1,A_2,...A_N) A=(A1?,A2?,...AN?)

找出有多少对整数 (i,j) ( 1 ≤ i < j ≤ N 1\le i<j \le N 1i<jN) 满足 j ? i = A i ? A j j-i=A_i-A_j j?i=Ai??Aj?

约束: 1 ≤ N ≤ 2 × 1 0 5 , 1 ≤ A i ≤ 2 × 1 0 5 ( 1 ≤ i ≤ N ) 1\le N\le 2\times 10^5,1\le A_i \le 2\times 10^5(1\le i\le N) 1N2×105,1Ai?2×105(1iN)

分析:数据范围较大,枚举复杂度为 O ( n 2 ) O(n^2) O(n2),考虑将原式变形:移项得 j ? a j = i + a i ≥ 2 j-a_j =i+a_i \ge 2 j?aj?=i+ai?2,可以发现左右两边均是与当前位置有关的信息。

s t [ x ] + + st[x] ++ st[x]++ 表示 x x x 出现的次数加一。

由于答案的更新在 s t st st 更新前,所以保证了 i < j i<j i<j

其实,无论答案更新在前还是在后,本题都不影响答案。证明如下:

  • 由于后续本就需要计算,所以只需要考虑当前是否影响答案即可。
  • 会影响答案的一定是 i + a i = i ? a i i+a_i=i-a_i i+ai?=i?ai?,但是这是不可能的,所以不会影响答案。

答案需要开 long long。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5, inf = 0x3f3f3f3f;
void solve() {
    ll n, ans = 0;
    cin >> n;
    vector<int> a(n + 1);
    map<int, int> st;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        ans += st[i - a[i]];
        st[i + a[i]]++;
    }
    cout << ans << "\n";
}
int main() {
    int T = 1;
    while (T--)
        solve();
    return 0;
}

D Takahashi’s Expectation

Takahashi will receive N N N presents.

He has a parameter called mood, which is a non-negative integer, and his mood changes every time he receives a present. Each present has three parameters: value P P P, mood increase A A A, and mood decrease B B B, and his mood changes as follows based on these parameters:

  • When the value P P P of the received present is greater than or equal to his mood, he is happy with the present, and his mood increases by A A A.
  • When the value P P P of the received present is less than his mood, he is disappointed with the present, and his mood decreases by B B B. However, if his mood is originally less than B B B, it becomes 0 0 0.

The i i i-th ( 1 ≤ i ≤ N ) (1\le i\le N) (1iN) present he receives has value P i P _ i Pi?, mood increase A i A _ i Ai?, and mood decrease B i B _ i Bi?.

You are given Q Q Q questions, so answer all of them. In the i i i-th ( 1 ≤ i ≤ Q ) (1\le i\le Q) (1iQ) question, you are given a non-negative integer X i X _ i Xi?, so answer the following question:

Find Takahashi’s mood after receiving all N N N presents when his mood is initially X i X _ i Xi?.

翻译:

高桥将收到 N N N 份礼物。

他有一个名为心情的参数,是一个非负整数,每次收到礼物时,他的心情都会发生变化。每件礼物都有三个参数:价值 P P P 、心情上升 A A A 、心情下降 B B B ,根据这些参数,他的心情会发生如下变化:

  • 当收到的礼物的值 P P P 大于或等于他的心情时,他对礼物感到高兴,心情增加 A A A
  • 当收到的礼物的价值 P P P 小于他的心情时,他对礼物感到失望,心情会降低 B B B 。但是,如果他的心情原本小于 B B B ,则会变成 0 0 0

他收到的 i i i /- ( 1 ≤ i ≤ N ) (1\le i\le N) (1iN) 份礼物的价值为 P i P _ i Pi? ,心情增加 A i A _ i Ai? ,心情减少 B i B _ i Bi?

你有 Q Q Q 个问题,请回答所有问题。在 i i i - ( 1 ≤ i ≤ Q ) (1\le i\le Q) (1iQ) 题中,你得到了一个非负整数 X i X _ i Xi? ,请回答下面的问题:

求高桥收到所有 N N N 礼物后的心情,当他的心情最初为 X i X _ i Xi? 时。

分析:
题目中数据如果采用暴力,复杂度为 O ( n q ) O(nq) O(nq),约 5 e 9 5e9 5e9——这里其实可以通过一些瞎搞的做法降低常数,大概降低 10 倍就可以通过了。自然,这在复杂度上是比较危险的。

正确的解法是这样的:可以看题目发现, P i , A i , B i ∈ [ 1 , 500 ] P_i,A_i,B_i \in [1,500] Pi?,Ai?,Bi?[1,500] X i ∈ [ 0 , 1 0 9 ] X_i\in [0,10^9] Xi?[0,109]
可以想到 X i X_i Xi? 的范围如此之大,实际上只需要和 500 500 500 进行比较,这是否可以考虑预处理一些较小的解,然后通过将 X X X 快速转为该区间的解,貌似可行。

预处理 d p i , j dp_{i,j} dpi,j? 表示开始情绪值为 j j j,从第 i i i 个礼物开始收取完所有礼物后的情绪值。

初始化: d p n + 1 , j = j dp_{n+1, j}=j dpn+1,j?=j
状态转移:
d p i , j = { d p i + 1 , j + a i ?if? j ≤ p i d p i + 1 , j ? a i ?if? j > p i dp_{i,j} = \begin{cases} dp_{i+1, j+a_i} & \text{ if } j\le p_i \\ dp_{i+1, j-a_i} & \text{ if } j> p_i \end{cases} dpi,j?={dpi+1,j+ai??dpi+1,j?ai????if?jpi??if?j>pi??
目标: d p 1 , x dp_{1,x} dp1,x?

  • x ≤ 1000 x\le 1000 x1000,可以直接得到答案 d p 1 , x dp_{1,x} dp1,x?
  • x > 1000 x>1000 x>1000,可以通过 x ? ∑ i = 1 k B i x-\sum_{i=1}^k B_i x?i=1k?Bi?,使得 x ≤ 1000 x\le 1000 x1000

由于 B i > 0 B_i>0 Bi?>0,所以构造的 B B B 前缀和 S i S_i Si? 是单调递增的,可以二分得到答案。
x ? S i ≤ 1000 → S i ≥ x ? 1000 x-S_i\le 1000 \to S_i \ge x-1000 x?Si?1000Si?x?1000
如果不存在 i i i 满足该不等式,则证明 S n < x ? 1000 S_n<x-1000 Sn?<x?1000,答案为 x ? S n x-S_n x?Sn?
如果存在 i i i 满足该不等式,则证明可以通过 x ? S i x-S_i x?Si? 使得 x ≤ 1000 x\le 1000 x1000,所以答案为 d p i + 1 , x ? S i dp_{i+1, x-S_i} dpi+1,x?Si??

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e4 + 5, inf = 0x3f3f3f3f;
int n, q, x, p[N], a[N], b[N], s[N], dp[N][1505];
signed main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i] >> a[i] >> b[i];
        s[i] = s[i - 1] + b[i];
    }
    for (int i = 0; i <= 1500; i++)
        dp[n + 1][i] = i;
    for (int i = n; i >= 0; i--)
        for (int j = 0; j <= 1000; j++)
            if (p[i] >= j)
                dp[i][j] = dp[i + 1][j + a[i]];
            else
                dp[i][j] = dp[i + 1][max(0, j - b[i])];
    cin >> q;
    while (q--) {
        cin >> x;
        if (x <= 1000) {
            cout << dp[1][x] << "\n";
            continue;
        }
        int i = lower_bound(s + 1, s + 1 + n, x - 1000) - s;
        if (i == n + 1)
            cout << x - s[n] << "\n";
        else
            cout << dp[i + 1][x - s[i]] << "\n";
    }
    return 0;
}

E A Path in A Dictionary

You are given a simple connected undirected graph G with N vertices and M edges.
The vertices of G are numbered vertex 1, vertex 2, …, vertex N, and the i-th ( 1 ≤ i ≤ M ) (1\le i \le M) (1iM) edge connects vertices U i U_i Ui? and V i V_i Vi?.

Find the lexicographically smallest simple path from vertex X to vertex Y in G.
That is, find the lexicographically smallest among the integer sequences P = ( P 1 , P 2 , … , P ∣ P ∣ ) P=(P1 ,P2 ,…,P_{∣P∣}) P=(P1,P2,,PP?) that satisfy the following conditions:

  • 1 ≤ P i ≤ N 1 \le P_i \le N 1Pi?N
  • If i ≠ j i\neq j i=j, then P i ≠ P j P_i\neq P_j Pi?=Pj?.
  • P 1 = X P_1=X P1?=X and P ∣ P ∣ = Y P_{∣P∣}=Y PP?=Y.
  • For 1 ≤ i ≤ ∣ P ∣ ? 1 1\le i\le ∣P∣?1 1i≤∣P?1, there exists an edge connecting vertices P i P_i Pi? and P i + 1 P_{i+1} Pi+1?.

One can prove that such a path always exists under the constraints of this problem.

You are given T test cases, so find the answer for each.

翻译:
给定一个简单的连通无向图 G ,它有 N 个顶点和 M 条边。
G 的顶点编号为顶点 1、2 、… 、N ,第 i 条 ( 1 ≤ i ≤ M ) (1\le i \le M) (1iM) 边连接顶点 U i U_i Ui? V i V_i Vi?
?在 G 中,找到从顶点 X 到顶点 Y 的字典序最小的简单路径。
也就是说,找到满足以下条件的整数序列 P = ( P 1 , P 2 , … , P ∣ P ∣ ) P=(P1 ,P2 ,…,P_{∣P∣}) P=(P1,P2,,PP?) 中字典序最小的序列:

  • 1 ≤ P i ≤ N 1 \le P_i \le N 1Pi?N
  • 如果 i ≠ j i\neq j i=j, 那么 P i ≠ P j P_i\neq P_j Pi?=Pj?.
  • P 1 = X P_1=X P1?=X P ∣ P ∣ = Y P_{∣P∣}=Y PP?=Y.
  • 对于 1 ≤ i ≤ ∣ P ∣ ? 1 1\le i\le ∣P∣?1 1i≤∣P?1, 存在一条边连接顶点 P i P_i Pi? P i + 1 P_{i+1} Pi+1?.

可以证明,在问题的约束条件下,这样的路径总是存在。
给出了 T 个测试用例,所以找出每个的答案。

分析:建图后按节点升序排序,dfs 遍历即可。

#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
const int N = 1e6 + 10, inf = 0x3f3f3f3f, inf2 = 1e18;
vector<int> G[N];
int a[N], n, m, x, y, p;
bool st[N], flag;

void dfs(int u) {
    if (flag) return;
    st[u] = 1, a[++p] = u;
    if (u == y) {
        for (int i = 1; i <= p; i++)
            cout << a[i] << " \n"[i == p];
        flag = 1; return;
    }
    for (auto& v : G[u]) {
        if (st[v]) continue;
        dfs(v);
    }
    --p;
}
void solve() {
    cin >> n >> m >> x >> y;
    p = 0, flag = 0;
    memset(st, 0x00, sizeof st);
    for (int i = 1; i <= n; i++) G[i].clear();
    for (int i = 1, u, v; i <= m; i++) {
        cin >> u >> v;
        G[u].push_back(v), G[v].push_back(u);
    }
    for (int i = 1; i <= n; i++) sort(G[i].begin(), G[i].end());
    dfs(x);
}
signed main() {
    int T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}

F Random Gathering

There are N N N plates arranged from left to right as plate 1 , 1, 1, plate 2 , … , 2,\ldots, 2,, plate N N N. Initially, plate i ? ( 1 ≤ i ≤ N ) i\ (1\le i\le N) i?(1iN) contains A i A _ i Ai? stones.

You will perform M M M operations on these plates. In the i i i-th operation ( 1 ≤ i ≤ M ) (1\le i\le M) (1iM), two integers L i L _ i Li? and R i R _ i Ri? are given, and the following operations are performed in order:

  • Remove all stones from the R i ? L i + 1 R _ i-L _ i+1 Ri??Li?+1 plates: plate L i , L _ i, Li?, plate L i + 1 , … , L _ i+1,\ldots, Li?+1,, plate R i R _ i Ri?.
  • Uniformly randomly choose an integer between L i L _ i Li? and R i R _ i Ri?, inclusive, and let it be x x x.
  • Place all the removed stones on plate x x x.

For i = 1 , 2 , … , N i=1,2,\ldots,N i=1,2,,N, find the expected number, modulo 998244353 998244353 998244353, of stones placed on plate i i i when all M M M operations are completed.

Finding expected value modulo 998244353 998244353 998244353

It can be proved that the expected value you seek is always a rational number. Also, under the constraints of this problem, when that value is expressed as an irreducible fraction P Q \frac{P}{Q} QP?, it can be proved that Q ≡? 0 ( m o d 998244353 ) Q \not\equiv 0 \pmod{998244353} Q0(mod998244353). Therefore, there is a unique integer R R R such that R × Q ≡ P ( m o d 998244353 ) , 0 ≤ R < 998244353 R \times Q \equiv P \pmod{998244353}, 0 \leq R \lt 998244353 R×QP(mod998244353),0R<998244353. Finding the expected value modulo 998244353 998244353 998244353 means finding this R R R.

翻译:

N N N 个盘子,从左到右排列为盘子 1 , 1, 1, 盘子 2 , … , 2,\ldots, 2,, 盘子 N N N 。最初,板块 i ? ( 1 ≤ i ≤ N ) i\ (1\le i\le N) i?(1iN) 包含 A i A _ i Ai? 块石头。

您将在这些板块上进行 M M M 次操作。在 i i i -th 运算 ( 1 ≤ i ≤ M ) (1\le i\le M) (1iM) 中,给出了两个整数 L i L _ i Li? R i R _ i Ri? ,并依次进行了以下运算:

  • 移除 R i ? L i + 1 R _ i-L _ i+1 Ri??Li?+1 盘中的所有棋子:盘子 L i , L _ i, Li?, 盘子 L i + 1 , … , L _ i+1,\ldots, Li?+1,, 盘子 R i R _ i Ri?
  • L i L _ i Li? R i R _ i Ri? (含)之间统一随机选择一个整数,让它成为 x x x
  • 将所有取出的棋子放入棋盘 x x x 中。

i = 1 , 2 , … , N i=1,2,\ldots,N i=1,2,,N 而言,求当所有 M M M 运算完成后,放置在 i i i 盘中的石子的预期数目(模为 998244353 998244353 998244353 )。

求模数 998244353 998244353 998244353 的期望值。

可以证明,所求的期望值总是一个有理数。另外,在本题的限制条件下,当该值表示为不可约分数 P Q \frac{P}{Q} QP? 时,可以证明 Q ≡? 0 ( m o d 998244353 ) Q \not\equiv 0 \pmod{998244353} Q0(mod998244353) 。因此,存在一个唯一的整数 R R R ,即 R × Q ≡ P ( m o d 998244353 ) , 0 ≤ R < 998244353 R \times Q \equiv P \pmod{998244353}, 0 \leq R \lt 998244353 R×QP(mod998244353),0R<998244353 。求模为 998244353 998244353 998244353 的期望值就是求这个 R R R

G Binary Cat

Define strings S 0 S_0 S0? and S 1 S_1 S1? as S 0 = S_0= S0?= 0 and S 1 = S_1= S1?= 1.
You are given Q Q Q queries, so process them in order.
In the i i i-th query ( 1 ≤ i ≤ Q ) (1\leq i\leq Q) (1iQ), you are given a triple of integers ( L i , R i , X i ) (L_i,R_i,X_i) (Li?,Ri?,Xi?).

Let S i + 1 S_{i+1} Si+1? be the string obtained by concatenating S L i S_{L_i} SLi?? and S R i S_{R_i} SRi?? in this order. Then, find the X i X_i Xi?-th character of S i + 1 S_{i+1} Si+1?.

It is guaranteed that X i X_i Xi? is at most the length of S i + 1 S_{i+1} Si+1?.

翻译:
将字符串 S 0 S_0 S0? S 1 S_1 S1? 定义为 S 0 = 0 S_0=0 S0?=0 S 1 = 1 S_1=1 S1?=1
我们会得到 Q Q Q 个查询,请按顺序处理它们。
i i i -查询 ( 1 ≤ i ≤ Q ) (1\leq i\leq Q) (1iQ) 中,你会得到一个整数三元组 ( L i , R i , X i ) (L_i,R_i,X_i) (Li?,Ri?,Xi?)

假设 S i + 1 S_{i+1} Si+1? 是按照这个顺序连接 S L i S_{L_i} SLi?? S R i S_{R_i} SRi?? 得到的字符串。然后,找出 S i + 1 S_{i+1} Si+1? X i X_i Xi? -th 字符。

可以保证 X i X_i Xi? 最多是 S i + 1 S_{i+1} Si+1? 的长度。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
维生素b什么时候吃 也许是什么意思 口嗨什么意思 touch什么意思 经常头晕吃什么食物好
犬瘟是什么原因引起的 特点是什么 孩子疱疹性咽峡炎吃什么药 锤子什么意思 番是什么意思
关节炎挂什么科 肺炎为什么要7到10天才能好 ngu是什么意思 热射病是什么 宝宝反复发烧是什么原因
老人双脚浮肿是什么原因 阴唇为什么一个大一个小 我们到底什么关系 作奸犯科是什么意思 盆腔积液吃什么药
敖虫读什么hcv7jop6ns2r.cn 缺镁吃什么药hcv8jop7ns8r.cn 醋精和白醋有什么区别hcv8jop6ns4r.cn 晚上十一点是什么时辰hcv8jop3ns4r.cn 感染hpv吃什么药jasonfriends.com
女人吃葛根粉有什么好处hcv7jop6ns2r.cn 人文是什么意思baiqunet.com 胸径是什么意思helloaicloud.com 鲜花又什么又什么hcv9jop1ns6r.cn 清明节一般开什么生肖hcv9jop0ns9r.cn
三虫念什么hcv8jop2ns6r.cn ems什么意思hcv7jop6ns6r.cn 羽毛球拍什么材质的好hcv9jop6ns2r.cn 黄瓜有什么功效hcv9jop5ns8r.cn 蒸馏水敷脸有什么作用hcv8jop7ns1r.cn
胃溃疡吃什么药好imcecn.com 肝虚吃什么中成药hcv7jop9ns8r.cn 换手率什么意思aiwuzhiyu.com 12月21日是什么星座travellingsim.com 吃冬瓜有什么好处hcv9jop4ns6r.cn
百度