题解
【入门】前缀最大值
1 条题解
-
0
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n,x; cin>>n>>x; ll sum=0; ll nowmax=0; ll cur=x; for(ll i=1;i<=n;i++){ if(cur>nowmax) nowmax=cur; sum+=nowmax; cur=(379*cur+131)%997; } cout<<sum; return 0; }
- 1