F - Predilection(dp)
Posted Harris-H
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了F - Predilection(dp)相关的知识,希望对你有一定的参考价值。
F - Predilection(dp)
比较显然的线性dp,但是我一开始不会。
开一个去重map即可。
// Problem: F - Predilection
// Contest: AtCoder - AtCoder Beginner Contest 230
// URL: https://atcoder.jp/contests/abc230/tasks/abc230_f
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Date: 2021-12-06 17:21:30
// --------by Herio--------
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=998244353;
const int hashmod[4] = 402653189,805306457,1610612741,998244353;
#define mst(a,b) memset(a,b,sizeof a)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define x first
#define y second
#define pb emplace_back
#define SZ(a) (int)a.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define ios ios::sync_with_stdio(false),cin.tie(nullptr)
void Print(int *a,int n)
for(int i=1;i<n;i++)
printf("%d ",a[i]);
printf("%d\\n",a[n]);
template <typename T> //x=max(x,y) x=min(x,y)
void cmx(T &x,T y)
if(x<y) x=y;
template <typename T>
void cmn(T &x,T y)
if(x>y) x=y;
int n;
unordered_map<ll,ll>mp;
ll f[N];
int main()
ll s;
scanf("%d%lld",&n,&s);
f[1] = 1;
for(int i=2;i<=n;i++)
int x;scanf("%d",&x);
f[i] = ((f[i-1]<<1) - mp[s] + mod)%mod;
mp[s] = f[i-1];
s+=x;
printf("%lld\\n",f[n]);
return 0;
以上是关于F - Predilection(dp)的主要内容,如果未能解决你的问题,请参考以下文章
添加两个窗格的平板电脑布局会导致在移动设备中找不到视图(小于w600dp)