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\)式子,我们会想到我们学习进制转换中学到的,那么我们就只需要 ...
随机推荐
- Debian 9 / Debian 10 / Ubuntu 18.04 / Ubuntu 18.10快速开启BBR加速 或 关闭BBR加速
如果使用的是Debian 9.Debian 10.Ubuntu 18.04.Ubuntu 18.10等内核高于4.9版本的系统,均可以使用此方法开启BBR加速,若你使用了Ubuntu 19.04的系统 ...
- 经实验验证,修正对using namespace std的认识
备注①:name:符号.指的实体包括:变量.函数.类 备注②:认为全局命名空间也是一个包,在此称作 ROOT:: 或 global:: (这样就有了两个特别的包:一个是全局包,一个是std包.但对于编 ...
- 2019 中至数据java面试笔试题 (含面试题解析)
本人5年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.中至数据等公司offer,岗位是Java后端开发,因为发展原因最终选择去了中至数据,入职一年时间了,也成为了面 ...
- Django---图书管理系统,一对多(外键设置),__str__和__repr__的区别,进阶版项目说明简介.模版语言if ... else ..endif
Django---图书管理系统,一对多(外键设置),__str__和__repr__的区别,进阶版项目说明简介.模版语言if ... else ..endif 一丶__str__ 和 __repr__ ...
- Vue搭建脚手架2
Vue2.0搭建Vue脚手架(vue-cli) 在网上找了很多的搭建脚手架教程,但都不求甚解.终于找到2个比较好的教程,读者可对比阅读1和2,在这里分享给大家,希望对初学者有所帮助.ps:高手请绕道. ...
- SAP CDS重定向视图和直接读这两者场景的性能比较
A very rough performance comparison is performed in ER9/001. Comparison scenario The two below opera ...
- VS2015配置Qt5
目录 需要准备的东西 VS2015 Qt5 VS2015 Qt插件 rc.exe无法启动 基于CMake的Qt工程 reference 需要准备的东西 Visual Studio 2015 Qt5 V ...
- Python 基础-> 字符串,数字,变量
Python 基础:字符串,数字,变量 1. 字符串 (信息的一种表达方式) a. 使用引号创建字符串 b. 单引号,双引号,三引号: ', ", ''', ""&quo ...
- matplotlib---插值画二维、三维图
一.画二维图 1.原始数据(x,y) import matplotlib.pyplot as plt import numpy as np #数据 X = np.array(list(i for i ...
- Android PKMS服务
它的作用? 关于PKMS的全称是啥应该咱们不陌生,PackageManagerService,和AMS一样是Android系统的核心服务,它主要负责系统中Package的管理,应用程序的安装.卸载.信 ...