当前位置:网站首页>Value sequence < detailed explanation of daily question >
Value sequence < detailed explanation of daily question >
2022-07-02 23:02:00 【CTGU-Yoghurt】
subject :
Topic link :
Ideas :
To do this problem, we must first understand a rule :
Here's the picture 
Then we can discuss it in these two cases
Be the first 1 In this case :
Its number of schemes is 2 Of i-j+1 Power
Be the first 2 In this case :
Its number of schemes is 2 Of i-j+1 Power -1( Remove the case of completely deleting the intermediate value )
Then why is the number of schemes 2 Of i-j+1 Power Well ?
as follows 
Code details :
#include<stdio.h>
#include<iostream>
using namespace std;
typedef long long ll;
ll a[(ll)2e5 + 6];
const int mod = 998244353;
ll qsm(ll x, ll y)// Fast power
{
ll ans = 1;
while (y)
{
if (y & 1) ans =ans*x%mod;
y =y>> 1;
x = x*x%mod;
}
return ans;
}
int main()
{
int t;
cin >> t;
while (t--)
{
int n; scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
ll ans = 1;
for (int i = 1; i <= n; i++)
{
int j = i;// Record the middle starting position
while (a[j + 1] == a[i]&&j<n) j++;// Take have
if (i >= 2 &&j<n&& ((a[j + 1]>a[i] && a[i]>a[i - 1]) || ((a[i] < a[i - 1]) && a[j + 1] < a[i])))
{
ans = ans*qsm(2, j - i + 1)%mod;
}// When satisfied i-1 To j+1 When the number in the range is single increase or single decrease ( And there can be equality in the middle ), Then for the case that all equal numbers can be deleted
else
{// The value in the middle is greater than the value on both sides or less than the value on both sides ( In this case, all intermediate values cannot be deleted ) And i be equal to 1 The situation of
ans =ans* (qsm(2, j - i+1)-1)%mod;
}
i = j;// Perform the next interval query
}
printf("%lld\n", ans);
}
return 0;
}PS: Dew from tonight white , The moon is my hometown .____ Du Fu 《 On a moonlit night, I remember my brother 》
边栏推荐
- Kubernetes uses the host name to allocate the pod on the specified node
- Jerry's fast touch does not respond [chapter]
- [LeetCode] 数组中的第K个最大元素【215】
- 2016. 增量元素之间的最大差值
- Hanging mirror security won four global infosec awards on rsac2022
- Golang's learning route
- World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
- 数组进阶提高
- Successfully changed Splunk default URL root path
- JS syntax ES6, ES7, es8, es9, ES10, es11, ES12 new features (Abstract)
猜你喜欢

Qt QScrollArea

Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly
![[chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM](/img/5d/c23ec16df6ce8d78207b635f59dc20.png)
[chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM

手写ORM(对象关系映射)增删改查

【板栗糖GIS】arcmap—为什么使用自定义捕捉的时候,经典捕捉的勾要去掉呢?

Analyse des données dossiers d'apprentissage - - analyse simple de la variance à facteur unique avec Excel

情感对话识别与生成简述

Construction of Hisilicon 3559 universal platform: draw a frame on the captured YUV image

Addition, deletion, modification and query of handwritten ORM (object relationship mapping)

The motivation of AES Advanced Encryption Protocol
随机推荐
[LeetCode] 存在重复元素【217】
高并发介绍及应对
Golang面试整理 三 简历如何书写
Golang的学习路线
2016. 增量元素之间的最大差值
Learning records of data analysis (II) -- simple use of response surface method and design expert
The threshold value of fusing proportion cannot be changed with sentinel, and setting the slow call proportion has no effect
WebRTC音视频采集和播放示例及MediaStream媒体流解析
[leetcode] reverse string [344]
创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
【板栗糖GIS】arcmap—如何批量修改注记要素的字体,颜色,大小等
Motivation du Protocole de chiffrement avancé AES
数据标注典型案例,景联文科技如何助力企业搭建数据方案
[chestnut sugar GIS] ArcMap - why should the tick of classic capture be removed when using custom capture?
Jerry's fast touch does not respond [chapter]
LeetCode 968. 监控二叉树
Qt QSplitter拆分器
Rails 3 activerecord: sort by association count - rails 3 activerecord: order by count on Association
Construction of Hisilicon 3559 universal platform: rotation operation on the captured YUV image
[羊城杯2020]easyphp
https://ac.nowcoder.com/acm/contest/23481/B