2019 NOIP 夏令营(模拟赛1)
一来到夏令营,第一天上机就考试,
哎,简直不让人活了
这难道是给我们的见面礼???
A
https://www.luogu.org/problemnew/show/P1197
- #include<iostream>
- #include<cstdio>
- #include<algorithm>
- #include<cmath>
- #include<cstring>
- #include<string>
- using namespace std;
- int n,m,q,len=;
- int last[],p[],father[],ans[];
- struct node
- {
- int x;
- int y;
- int next;
- } qwq[];
- bool bz[];
- void add(int x,int y)
- {
- qwq[++len].x=x;
- qwq[len].y=y;
- qwq[len].next=last[x];
- last[x]=len;
- }
- int find(int x)
- {
- if(father[x]!=x)
- {
- father[x]=find(father[x]);
- }
- return father[x];
- }
- int main()
- {
- int x,y;
- scanf("%d %d",&n,&m);
- for(int i=;i<=n;i++)
- {
- last[i]=-;
- father[i]=i;
- }
- for(int i=;i<=m;i++)
- {
- scanf("%d %d",&x,&y);
- add(x,y);
- add(y,x);
- }
- scanf("%d",&q);
- for(int i=;i<=q;i++)
- {
- scanf("%d",&p[i]);
- bz[p[i]]=true;
- }
- int tot1=n-q;
- m=m<<;
- for(int i=;i<=m;i++)
- {
- int x=qwq[i].x,y=qwq[i].y,t1=find(x),t2=find(y);
- if(!bz[x]&&!bz[y]&&t1!=t2)
- {
- tot1--;
- father[t1]=t2;
- }
- }
- ans[q+]=tot1;
- for(int k=q;k>=;k--)
- {
- int x=p[k];
- bz[x]=false;
- tot1++;
- for(int i=last[x];i!=-;i=qwq[i].next)
- {
- int t1=find(x),y=qwq[i].y,t2=find(y);
- if(!bz[y]&&t1!=t2)
- {
- tot1--;
- father[t1]=t2;
- }
- }
- ans[k]=tot1;
- }
- for(int i=;i<=q+;i++)
- {
- printf("%d\n",ans[i]);
- }
- return ;
- }
B
https://www.luogu.org/problemnew/show/CF804B
- #include<iostream>
- #include<cstdio>
- #include<cstring>
- #include<algorithm>
- using namespace std;
- const int Mod=1e9+;
- int main()
- {
- string s;
- cin>>s;
- int xx=;
- int sum1=;
- int len=s.length();
- for(int i=len-;i>=;i--)
- {
- if(s[i]=='a')
- {
- sum1=(sum1+xx)%Mod;
- xx=xx*%Mod;
- }
- else if(s[i]=='b')
- {
- xx++;
- }
- }
- cout<<sum1<<endl;
- return ;
- }
C
https://www.luogu.org/problemnew/show/CF798C
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- using namespace std;
- int gcd(int x,int y)
- {
- if(y==)
- {
- return x;
- }
- else
- {
- return gcd(y,x%y);
- }
- }
- int a[];
- int main()
- {
- int n;
- cin>>n;
- for(int i=;i<n;i++)
- {
- cin>>a[i];
- }
- int xx=;
- int ans=;
- int t;
- for(int i=;i<n;i++)
- {
- xx=gcd(xx,a[i]);
- }
- if(xx>)
- {
- cout<<"Yes"<<endl<<""<<endl;
- }
- else
- {
- for(int i=;i<n-;i++)
- {
- while(abs(a[i])%==)
- {
- ans++;
- t=a[i];
- a[i]=a[i]-a[i+];
- a[i+]=t+a[i+];
- }
- }
- while(abs(a[n-])%==)
- {
- ans++;
- t=a[n-];
- a[n-]=a[n-]-a[n-];
- a[n-]=t+a[n-];
- }
- if(ans)
- {
- cout<<"YES"<<endl<<ans<<endl;
- }
- else
- {
- cout<<"NO"<<-<<endl;
- }
- }
- return ;
- }
2019 NOIP 夏令营(模拟赛1)的更多相关文章
- NOIP前模拟赛总结
NOIP前模拟赛总结 from 2018.10.7 to ??? Date Name Score(Rank) Problems 2018.10.7 McfXH AK Contest 42(?) 期望得 ...
- NOIP一系列模拟赛小结
NOIP越发接近了,于是自己也跟着机房的几位师兄一起做了几次NOIP模拟赛,收获颇多. #1-T1:求点集中的点能否只用三条与坐标轴平行的直线就能全部被经过,其实只要将横纵坐标排序后逐个点检查下就行. ...
- NOIP欢乐模拟赛 T1 解题报告
小澳的方阵 (matrix.cpp/c/pas) [题目描述] 小澳最近迷上了考古,他发现秦始皇的兵马俑布局十分有特点,热爱钻研的小澳打算在电脑上还原这个伟大的布局. 他努力钻研,发现秦始皇布置兵马俑 ...
- 2019.11.11 模拟赛 T2 乘积求和
昨天 ych 的膜你赛,这道题我 O ( n4 ) 暴力拿了 60 pts. 这道题的做法还挺妙的,我搞了将近一天呢qwq 题解 60 pts 根据题目给出的式子,四层 for 循环暴力枚举统计答案即 ...
- LUOGU NOIP 2018 模拟赛 DAY1
T1 传送门 解题思路 这似乎是小学数学知识???mod 9就相当于各位之和mod 9,打表求了个逆元,等差数列求和公式就行了. #include<iostream> #include&l ...
- 【NOIP考前模拟赛】纯数学方法推导——旅行者问题
一.写在前面 这题似乎是一道原创题目(不是博主原创),所以并不能在任何OJ上评测,博主在网盘上上传了数据(网盘地址:http://pan.baidu.com/s/1mibdMXi),诸位看官需者自取. ...
- NOIP欢乐模拟赛 T3 解题报告
3.小澳的葫芦 (calabash.cpp/c/pas) [题目描述] 小澳最喜欢的歌曲就是<葫芦娃>. 一日表演唱歌,他尽了洪荒之力,唱响心中圣歌. 随之,小澳进入了葫芦世界. 葫芦世界 ...
- NOIP欢乐模拟赛 T2 解题报告
小澳的坐标系 (coordinate.cpp/c/pas) [题目描述] 小澳者表也,数学者景也,表动则景随矣. 小澳不喜欢数学,可数学却待小澳如初恋,小澳睡觉的时候也不放过. 小澳的梦境中出现了一个 ...
- [luogu#2019/03/10模拟赛][LnOI2019]长脖子鹿省选模拟赛赛后总结
t1-快速多项式变换(FPT) 题解 看到这个\(f(x)=a_0+a_1x+a_2x^2+a_3x^3+ \cdots + a_nx^n\)式子,我们会想到我们学习进制转换中学到的,那么我们就只需要 ...
随机推荐
- mysql 事务的实现原理
开篇 相信大家都用过事务以及了解他的特点,如原子性(Atomicity),一致性(Consistency),隔离型(Isolation)以及持久性(Durability)等.今天想跟大家一起研究下事务 ...
- Google Guava Cache 全解析
Google guava工具类的介绍和使用https://blog.csdn.net/wwwdc1012/article/details/82228458 LoadingCache缓存使用(Loadi ...
- 2019 吉比特java面试笔试题 (含面试题解析)
本人5年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.吉比特等公司offer,岗位是Java后端开发,因为发展原因最终选择去了吉比特,入职一年时间了,也成为了面试官 ...
- localStorage、sessionStorage、Cookie的区别及用法
1.webstorage 本地存储,存储在客户端,包括localStorage和sessionStorage. (1)localStorage:生命周期是永久,这意味着除非用户显示在浏览器提供的UI上 ...
- 阿里熔断限流Sentinel研究
1. 阿里熔断限流Sentinel研究 1.1. 功能特点 丰富的应用场景:例如秒杀(即突发流量控制在系统容量可以承受的范围).消息削峰填谷.集群流量控制.实时熔断下游不可用应用等 完备的实时监控:S ...
- 13、vue如何解决跨域问题
开发环境:配置config文件夹中index.js文件: proxyTable: { '/api': { target: 'http://10.10.1.242:8245',//后端地址 // sec ...
- 英文INSURAUNCE保险INSURAUNCE词汇
世界保险INSURAUNCE 人类社会从开始就面临着自然灾害和意外事故的侵扰,在与大自然抗争的过程中,古代人们就萌生了对付灾害事故的保险思想和原始形态的保险方法.公元前2500年前后,古巴比伦王国国王 ...
- MySQL导入数据报错Got a packet bigger than‘max_allowed_packet’bytes错误的解决方法
由于max_allowed_packet的值设置过小的原因,只需要将max_allowed_packet值设置大一点就OK了.通过终端进入mysql控制台,输入如下命令可以查看max_allowed_ ...
- C语言深入学习
计算机存储篇 1.计算机对数据类型的辨别: 编译器在编译C程序时将其转变为汇编指令,其中指明了数据类型.此外,每种数据类型都有固定的存储长度,计算机运行程序时,会根据具体类型 读出相应长度的数据进行计 ...
- NIO与网络编程系统化学习
1.背景 数据在网络中传输,必然回遇到读写问题.... 2.比较NIO与IO 3.案例演示 3.1.缓冲区演示 package com.wfd360.nio; import org.junit.Tes ...