Codeforces Round 493

心情不好,被遣散回学校 ,心态不好 ,为什么会累,一直微笑就好了

#include<bits/stdc++.h>
using namespace std;
int main()
{freopen("in","r",stdin);\freopen("out","w",stdout);int n ,k=0,s=0,a[10];cin>>n;for(int i=0;i<n;i++){cin>>a[i];if(a[i]<a[k]) k=i;s+=a[i];}if(n<2||a[k]==s-a[k]){cout<<-1;}else{cout<<1<<" "<<k+1<<endl;} 
}
View Code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = (int)1e4+5;
ll arr[maxn],n,k;
int main()
{cin>>n>>k;for(int i=0;i<n;i++) cin>>arr[i];ll num1=0 ,num2=0;vector<long long> v;for(int i=0;i<n-1;i++){if(arr[i]&1)num1++;else num2++;if(num1    == num2) v.push_back(abs(arr[i]-arr[i+1]));}ll s= 0,ans=0;if(v.size()==0) cout<<0<<endl;else{sort(v.begin(),v.end());for(int i=0;i<v.size();i++){s+=v[i];if(s>k)break;ans++;}cout<<ans<<endl;}}
View Code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{freopen("in","r",stdin);\freopen("out","w",stdout); string str;ll n,m,k;cin>>n>>m>>k>>str;vector<int> v;int ans=0;if(str[0]=='0')ans =1;for(int i=1;i<n;i++){if(str[i]=='0'&&str[i-1]!='0') ans++;}ll cnt = LLONG_MAX;for(int i=0;i<ans;i++){cnt = min(cnt,m*i+k*(ans-i));}cout<<(cnt==LLONG_MAX?0:cnt) <<endl;
}
View Code
#include<bits/stdc++.h>
using namespace std;
#define REP(i,l,r) for(int i=l;i<=r;i++)
int main()
{set<long long> s;long long n;cin>>n;if(n<=10){REP(i,0,n) REP(j,0,n)REP(k,0,n)REP(l,0,n){if(i+j+k+l==n) s.insert(50*l+10*k+5*j+i);}cout<<s.size()<<endl;}else cout<<49ll*n-247<<endl;
}
View Code
#include<iostream>using namespace std;typedef long long ll;const ll mod = 998244353;ll pow(ll a, ll b) {ll ans = 1;while (b) {if (b & 1) {ans = ans * a % mod;}b >>= 1;a = a * a % mod;}return ans;
}int main() {ll n ;cin>>n;ll ans =0,cur= 1;for(int i=1;i<=n;i++){cur = cur*(n+1-i)*pow(i,mod-2);ll sign = pow(-1,i+1);ll val = pow(3,i)*pow(3,n*(n-i));ans = ans+(cur*sign*val);}ans = ans*2;cur =1 ;#if 0{cur = cur * (N + 1 - i) % mod * pow(i, mod - 2) % mod;ll sign = pow(-1, i + 1);ll val = pow(3, i) * pow(3, N * (N - i)) % mod;ans = (ans + (cur * sign * val) % mod) % mod;}ans = ans * 2 % mod;cur = 1;for (int i = 0; i < N; ++i) {ll sign = pow(-1, i + 1);ll val = (pow(-pow(3, i) + 1, N) - (pow(-pow(3, i), N))) % mod * 3 % mod;ans = (ans + cur * sign * val % mod) % mod;cur = cur * (N - i) % mod * pow(i + 1, mod - 2) % mod;}ans = (ans + mod) % mod;cout << ans << endl;return 0;#endif 
}
View Code
 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353 ;
ll ans,n;
ll q_pow(ll x,ll y)
{ll ans =1;while(y){if(y&1) ans = ans*x%mod;x=x*x%mod;y>>=1;}return ans;
}
int main()
{cin>>n;ans  = q_pow(3,n*n) - q_pow(q_pow(3,n)-3,n);for(ll i =0 ,t=1;i<=n;i++){ll b = q_pow(3,n-i);ll res = t*(q_pow(b,n) - q_pow(b-(i?1:3)+mod,n))%mod;if(i) res = res*3%mod;ans+=i&1?-res:res;t =t*(n-i)%mod*q_pow(i+1,mod-2)%mod;}cout<<(ans%mod+mod)%mod;
}
View Code
#include<bits/stdc++.h>
using namespace std; 
using namespace std;typedef long long ll;const int N = 4010, K = 80, P = 998244353;int k;
int comb[K][K];
int a1[K], a2[K];
pair<int, int> t1[N], t2[N];void solve(int n, pair<int, int>* t, int* a);int main() {int n, m;scanf("%d%d%d", &n, &m, &k);if (k % 2) {puts("0");return 0;}k /= 2;for (int i = 1; i < n; ++i)scanf("%d%d", &t1[i].first, &t1[i].second);for (int i = 1; i < m; ++i)scanf("%d%d", &t2[i].first, &t2[i].second);solve(n, t1, a1);solve(m, t2, a2);for (int i = 0; i <= k * 2; ++i) {comb[i][0] = 1;for (int j = 1; j <= i; ++j) {comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];if (comb[i][j] >= P)comb[i][j] -= P;}}int ans = 0;for (int i = 0; i <= k; ++i)ans = (ans + (ll)comb[k * 2][i * 2] * a1[i] % P * a2[k - i] % P) % P;printf("%d\n", ans);return 0;
}void solve(int n, pair<int, int>* t, int* a) {static int dp[K][N * 3], sum[K][N];memset(dp, 0, sizeof(dp));memset(sum, 0, sizeof(sum));for (int i = 0; i <= n * 3 - 2; ++i)dp[0][i] = 1;for (int i = 1; i <= k; ++i) {for (int e = 1; e < n; ++e) {int u = t[e].first, v = t[e].second;sum[i - 1][u] += dp[i - 1][n * 2 - 1 + e];if (sum[i - 1][u] >= P)sum[i - 1][u] -= P;sum[i - 1][v] += dp[i - 1][n + e];if (sum[i - 1][v] >= P)sum[i - 1][v] -= P;}for (int j = 0; j < i; ++j) {for (int e = 1; e < n; ++e) {int u = t[e].first, v = t[e].second;dp[i][u] = (dp[i][u] + dp[j][u] * (ll)dp[i - j - 1][n * 2 - 1 + e]) % P;dp[i][v] = (dp[i][v] + dp[j][v] * (ll)dp[i - j - 1][n + e]) % P;dp[i][n + e] = (dp[i][n + e] + dp[j][n + e] * (ll)(sum[i - j - 1][u] - dp[i - j - 1][n * 2 - 1 + e]) % P + P) % P;dp[i][n * 2 - 1 + e] = (dp[i][n * 2 - 1 + e] + dp[j][n * 2 - 1 + e] * (ll)(sum[i - j - 1][v] - dp[i - j - 1][n + e]) % P + P) % P;}}}for (int i = 0; i <= k; ++i) {for (int u = 1; u <= n; ++u) {a[i] += dp[i][u];if (a[i] >= P)a[i] -= P;}}
}
View Code
这个真的没有心情切掉,看看诡异的算法
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){static char buf[100000],*p1=buf,*p2=buf;return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){ll x = 0; char ch = gc(); bool positive = 1;for (; !isdigit(ch); ch = gc())    if (ch == '-')    positive = 0;for (; isdigit(ch); ch = gc())    x = x * 10 + ch - '0';return positive ? x : -x;
}
inline void write(ll a){if(a<0){a=-a; putchar('-');}if(a>=10)write(a/10);putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=120005,block=300,B=N/block+3,inf=1000000005;
int n,q,a[N],belong[N],mzs[N],p[N],l[N],r[N],q1[N],q2[N],t1,t2,val[N],cnt[B],lazy[B],L[B],R[B];
PI mn[N];
ll ans[N];
PI operator +(PI a,PI b){if(a.second==0)return b; else if(b.second==0)return a;return a.first==b.first?mp(a.first,a.second+b.second):(a.first>b.first?a:b);
}
void bao(int l,int r,int x){//cout<<l<<" "<<r<<" "<<x<<endl;int id=belong[l];for(int i=l;i<=r;i++)a[i]+=x;mn[id]=mp(inf,0); for(int i=L[id];i<=R[id];i++)mn[id]=mn[id]+mp(a[i],1);
}
void down(int x){if(!mzs[x])return;for(int i=L[x];i<=R[x];i++)if(a[i]==mn[x].first){val[i]+=mzs[x];}mzs[x]=0;
}
void ins(int l,int r,int x){if(l>r)return;if(belong[l]==belong[r]){down(belong[l]); bao(l,r,x); return;}down(belong[l]); bao(l,R[belong[l]],x);down(belong[r]); bao(L[belong[r]],r,x);for(int i=belong[l]+1;i<belong[r];i++)lazy[i]+=x;
}
void upd(){for(int i=1;i<=belong[n];i++)if(mn[i].first+lazy[i]==0){mzs[i]++; cnt[i]+=mn[i].second;}
}
ll ask(int l){ll ans=0; down(belong[l]);for(int i=l;i<=R[belong[l]];i++)ans+=val[i];for(int i=belong[l]+1;i<=belong[n];i++)ans+=cnt[i];return ans;
}
vector<int> v[N];
int main(){n=read();for(int i=1;i<=n;i++){p[i]=read();if((i-1)%block==0)L[belong[i]=belong[i-1]+1]=i; else belong[i]=belong[i-1];R[belong[i]]=i;a[i]=-1; mn[belong[i]]=mn[belong[i]]+mp(-1,1);}q=read();for(int i=1;i<=q;i++){l[i]=read(); r[i]=read();v[r[i]].push_back(i);}for(int i=1;i<=n;i++){while(p[q1[t1]]<p[i]&&t1){ins(q1[t1-1]+1,q1[t1],-p[i]+p[q1[t1]]); t1--; }q1[++t1]=i;while(p[q2[t2]]>p[i]&&t2){ins(q2[t2-1]+1,q2[t2],p[i]-p[q2[t2]]); t2--;}q2[++t2]=i;ins(1,i,1); upd();//for(int i=1;i<=n;i++)cout<<a[i]<<" "; puts("");//cout<<mzs[1]<<" "<<mn[1].first<<" szb"<<lazy[1]<<" "<<cnt[2]<<" "<<endl;for(unsigned j=0;j<v[i].size();j++)ans[v[i][j]]=ask(l[v[i][j]]);}for(int i=1;i<=q;i++)writeln(ans[i]);
} 
View Code

 

转载于:https://www.cnblogs.com/corx/p/9288715.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/389192.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

android动画笔记二

从android3.0&#xff0c;系统提供了一个新的动画&#xff0d;property animation, 为什么系统会提供这样一个全新的动画包呢&#xff0c;先来看看之前的补间动画都有什么缺陷吧1、传统的补间动画都是固定的编码&#xff0c;功能是固定的&#xff0c;扩展难度大。比如传统动画只…

回归分析检验_回归分析

回归分析检验Regression analysis is a reliable method in statistics to determine whether a certain variable is influenced by certain other(s). The great thing about regression is also that there could be multiple variables influencing the variable of intere…

是什么样的骚操作让应用上线节省90%的时间

优秀的程序员 总会想着 如何把花30分钟才能解决的问题 在5分钟内就解决完 例如在应用上线这件事上 通常的做法是 构建项目在本地用maven打包 每次需要clean一次&#xff0c;再build一次 部署包在本地ide、git/svn、maven/gradie 及代码仓库、镜像仓库和云平台间 来回切换 上传部…

QQ API

QQ API设计说明书目录一、引言 31.1 编写目的 31.2 更新时间 3二、总体设计 3三、注册的系统消息 33.1 WM_QQAPI_REGISTER 33.2 WM_QQAPI_REGISTER_RESP 43.3 WM_QQAPI_AVAILABLE 4四、从设备到QQ的自定义事件 54.1 EVENT_QQAPI_SET_AUDIODEVICE …

Ubuntu 18.04 下如何配置mysql 及 配置远程连接

首先是大家都知道的老三套&#xff0c;啥也不说上来就放三个大招&#xff1a; sudo apt-get install mysql-serversudo apt isntall mysql-clientsudo apt install libmysqlclient-dev 这三步下来mysql就装好了&#xff0c;然后我们偷偷检查一下 sudo netstat -tap | grep mysq…

数据科学与大数据技术的案例_主数据科学案例研究,招聘经理的观点

数据科学与大数据技术的案例I’ve been in that situation where I got a bunch of data science case studies from different companies and I had to figure out what the problem was, what to do to solve it and what to focus on. Conversely, I’ve also designed case…

导致View树遍历的时机

遍历View树意味着整个View需要重新对其包含的子视图分配大小并重绘&#xff0c;导致重新遍历的原因主要有三个 1.视图本身内部状况变化引起重绘。 2.第二个是View树内部添加或者删除了View。 3.View本身的大小及可见性发生变化。 能引起View树重新遍历的操作&#xff0c;总…

什么是Hyperledger?Linux如何围绕英特尔的区块链项目构建开放平台?

访问区块链会议并关注区块链新闻时&#xff0c;不可避免地&#xff0c;您会遇到Linux基金会的Hyperledger。理解像比特币、以太坊这样的加密货币还算相对容易的&#xff0c;Hyperledger却不然。但如果你多研究研究&#xff0c;你会发现一些令人兴奋的非货币、工业区块链的应用项…

队列的链式存储结构及其实现_了解队列数据结构及其实现

队列的链式存储结构及其实现A queue is a collection of items whereby its operations work in a FIFO — First In First Out manner. The two primary operations associated with them are enqueue and dequeue.队列是项目的集合&#xff0c;由此其操作以FIFO(先进先出)的方…

安装

、添加一个新项目->选择类库模板->命名为DBCustomAction 2、单击项目右键->添加新项->选择安装程序类(命名为DBCustomAction.cs) 3、在 服务器资源管理器中添加->连接到 数据库->指定用户密码(选择允许保存密码)-> 数据库选择master 4、切换到DBCustomAct…

cad2016珊瑚_预测有马的硬珊瑚覆盖率

cad2016珊瑚What’s the future of the world’s coral reefs?世界珊瑚礁的未来是什么&#xff1f; In February of 2020, scientists at University of Hawaii Manoa released a study addressing this very question. The models they developed forecasted a 70–90% worl…

EChart中使用地图方式总结(转载)

EChart中使用地图方式总结 2018年02月06日 22:18:57 来源&#xff1a;https://blog.csdn.net/shaxiaozilove/article/details/79274772最近在仿照EChart公交线路方向示例&#xff0c;开发表示排水网和污水网流向地图&#xff0c;同时地图上需要叠加排放口、污染源、污水处理厂等…

android mvp模式

越来越多人讨论mvp模式&#xff0c;mvp在android应用开发中获得更多的重视&#xff0c;这里说一下对MVP的简单了解。 什么是 MVP? MVP模式使逻辑从视图层分开&#xff0c;目的是我们在屏幕上怎么表现&#xff0c;和界面如何工作的所有事情就完全分开了。 View显示数据&…

Node.js REPL(交互式解释器)

2019独角兽企业重金招聘Python工程师标准>>> Node.js REPL(交互式解释器) Node.js REPL(Read Eval Print Loop:交互式解释器) 表示一个电脑的环境&#xff0c;类似 Window 系统的终端或 Unix/Linux shell&#xff0c;我们可以在终端中输入命令&#xff0c;并接收系统…

中国移动短信网关CMPP3.0 C#源代码:使用示例

中国移动短信网关CMPP3.0 C#源代码&#xff1a;使用示例 中国移动短信网关CMPP3.0 C#源代码使用&#xff0c;在上一篇文章中我介绍过cmpp3.0,这段时间因为也做关于移动短信网关的开发&#xff0c;在这里给大家一个演示如何使用cmpp3.0开发移动短信网关。Using Tiray.SMS... Ti…

用python进行营销分析_用python进行covid 19分析

用python进行营销分析Python is a highly powerful general purpose programming language which can be easily learned and provides data scientists a wide variety of tools and packages. Amid this pandemic period, I decided to do an analysis on this novel coronav…

名称

命名规则&#xff1a;Go中函数、变量、常量、类型、语句标签和包的名称都遵循一个规则&#xff0c;开头是一个字母或下划线&#xff0c;后面跟任意字符、数字和下划线&#xff0c;并区分大小写。例如&#xff1a;heapSort和HeapSort是不同名称。关键字&#xff1a;Go有25个关键…

Alpha冲刺第二天

Alpha第二天 1.团队成员 郑西坤 031602542 &#xff08;队长&#xff09; 陈俊杰 031602504陈顺兴 031602505张胜男 031602540廖钰萍 031602323雷光游 031602319苏芳锃 0316023302.项目燃尽图 3.项目进展 时间工作内容11月18日UI设计、初步架构搭建11月19日UI设计、服务器的进一…

Tiray.SMSTiray.SMSTiray.SMSTiray.SMSTiray.SMSTiray.SMS

这是2005年6月云南移动短信网关升级到3.0时写的&#xff0c;在SP那稳定运行了很长时间的。因为SP倒闭了&#xff0c;贴出来给有兴趣的朋友参考。优点&#xff1a;支持多线程、滑动窗口、异步发送、全事件模式、自动识别ASCII、GBK、UCS-2缺点&#xff1a;不支持长短信自动分页、…

水文分析提取河网_基于图的河网段地理信息分析排序算法

水文分析提取河网The topic of this article is the application of information technologies in environmental science, namely, in hydrology. Below is a description of the algorithm for ranking rivers and the plugin we implemented for the open-source geographic…