ACM-NEFU15届校赛-大二组
A.小林找工作
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+10;
int p[MAXN];
int main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
scanf("%d", &p[i]);
}
sort(p+1,p+n+1);
for(int i=0;i<m;i++)
{
int temp;
scanf("%d", &temp);
int pos=lower_bound(p+1,p+n+1,temp)-p;
if(pos>n) pos=n;
int ans=abs(temp-p[pos]);
if(pos!=1) ans=min(ans, abs(temp-p[pos-1]));
printf("%d\n", ans);
}
return 0;
}
B.xx的树
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+10;
typedef long long ll;
typedef struct{
int to;
int next;
}edge;
edge e[MAXN];
int cur=1,head[MAXN],vis[MAXN];
ll value[MAXN];
void add(int u,int v)
{
e[cur].to=v;
e[cur].next=head[u];
head[u]=cur++;
}
void dfs(int u)
{
vis[u]=1;
for(int i=head[u];i!=0;i=e[i].next)
{
int v=e[i].to;
if(vis[v]) continue;
value[v]+=value[u];
dfs(v);
}
}
int main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<n;i++)
{
int u,v;
cin>>u>>v;
add(u,v);
add(v,u);
}
for(int i=1;i<=m;i++)
{
ll u,d;
cin>>u>>d;
value[u]+=d;
}
dfs(1);
for(int i=1;i<=n;i++)
i==1?cout<<value[i]:cout<<" "<<value[i];
return 0;
}
C.xx玩游戏
找到规律,偶数列没有必败态,奇数列有(n+1)/2个必败态
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int t;
cin>>t;
while(t--)
{
ll n;
scanf("%lld", &n);
ll t=(n+1)/2;
ll lose=(1+t)*t/2;
ll sum=(1+n)*n/2;
printf("%lld\n", sum-lose);
}
return 0;
}
D. xx的零食店(待补)
E.qyh的签到题
跟去年校赛大一的一道题神似...
#include<bits/stdc++.h>
using namespace std;
int n,q;
typedef long long ll;
const long long mod=1e9+7;
const int MAXN=1e5+5;
ll d1[MAXN],d2[MAXN],d3[MAXN];
void pre_sum(ll d[])
{
for(int i=1;i<=n;i++)
{
d[i]+=d[i-1];
d[i]%=mod;
}
}
int main()
{
scanf("%d%d",&n, &q);
for(int i=0;i<q;i++)
{
int type,pos;
scanf("%d%d", &type, &pos);
if(type==1) d1[pos]++;
if(type==2) d2[pos]++;
if(type==3)
{
d3[pos]++;
d3[pos+1]++;
}
}
pre_sum(d3); pre_sum(d3); pre_sum(d3);
pre_sum(d2); pre_sum(d2);
pre_sum(d1);
for(int i=1;i<=n;i++)
{
i==1?printf("%lld", (d1[i]+d2[i]+d3[i])%mod):printf(" %lld", (d1[i]+d2[i]+d3[i])%mod);
}
return 0;
}
G.天哥的序列
ACM-NEFU15届校赛-大二组的更多相关文章
- 河南省acm第九届省赛--《表达式求值》--栈和后缀表达式的变形--手速题
表达式求值 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 假设表达式定义为:1. 一个十进制的正整数 X 是一个表达式.2. 如果 X 和 Y 是 表达式,则 X+Y, ...
- CSUST 第15届 校赛总结
一直想记录一下自己的比赛,却感觉空间说说有点不适,思考了一番还是打算放到自己的博客园 这次比赛总体来说还是不错,签到还是稳的一批,基本前四小时都在rk1 开局切了几道签到题,然后开了一道思维gcd,正 ...
- 【Nowcoder 上海五校赛】二数(模拟)
题目描述: 我们把十进制下每一位都是偶数的数字叫做“二数”. 小埃表示自己很聪明,最近他不仅能够从小数到大:2,3,4,5....,也学会了从大数到小:100,99,98...,他想知道从一个数开始数 ...
- 广工十四届校赛 count 矩阵快速幂
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6470 题意:求,直接矩阵快速幂得f(n)即可 构造矩阵如下: n^3是肯定得变换的,用二项式展开来一点 ...
- 之江学院第0届校赛 qwb与支教 (容斥公式)
description qwb同时也是是之江学院的志愿者,暑期要前往周边地区支教,为了提高小学生的数学水平.她把小学生排成一排,从左至右从1开始依次往上报数. 玩完一轮后,他发现这个游戏太简单了.于是 ...
- Sdut 2165 Crack Mathmen(数论)(山东省ACM第二届省赛E 题)
Crack Mathmen TimeLimit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Since mathmen take security ...
- ACM Sdut 2158 Hello World!(数学题,排序) (山东省ACM第一届省赛C题)
题目描述 We know thatIvan gives Saya three problems to solve (Problem F), and this is the firstproblem. ...
- 之江学院第0届校赛 qwb去面试 (找规律)
Description 某一天,qwb去WCfun面试,面试官问了他一个问题:把一个正整数n拆分成若干个正整数的和,请求出这些数乘积的最大值. qwb比较猥琐,借故上厕所偷偷上网求助,聪明的你能帮助他 ...
- Sdut 2164 Binomial Coeffcients (组合数学) (山东省ACM第二届省赛 D 题)
Binomial Coeffcients TimeLimit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 输入 输出 示例输入 1 1 10 2 9 ...
- Sdut 2151 Phone Numbers (山东省ACM第一届省赛题 A)
题目描述 We know thatif a phone number A is another phone number B's prefix, B is not able to becalled. ...
随机推荐
- keras构建1D-CNN模型
接触过深度学习的人一定听过keras,为了学习的方便,接下来将要仔细的讲解一下这keras库是如何构建1D-CNN深度学习框架的 from keras.datasets import imdb fro ...
- 【APT】Hades APT组织针对乌克兰发起网络攻击事件分析
背景 Hades一个充满神秘色彩的APT组织,该组织因为2017年12月22日针对韩国平昌冬奥会的攻击活动被首次发现,后来卡巴斯基将该次事件的攻击组织命名为Hades.但是该攻击组织的归属问题却一直未 ...
- 【jupyter notebook】配置基于ecs云平台的jupyter notebook远程使用
学校提供了ecs云服务器进行高性能运算 分配到了云主机后想在上面搭好jupyter notebook服务器方便远程使用,在此记录整个流程和遇到的问题 本文档适用于常规的jupyter notebook ...
- 运行python脚本报错SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
运行python脚本报错 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: ...
- shell命令查找文件
1.find命令的参数下面是find命令一些常用参数的例子,有用到的时候查查就行了,像上面前几个贴子,都用到了其中的的一些参数,也可以用man或查看论坛里其它贴子有find命令手册使用name选项文件 ...
- Delphi之不可思议
1.--------不可思议的函数调用--开始- 开发环境D7 1 function TForm1.GetssA: string; 2 begin 3 Result:=Result+'AA'; 4 e ...
- Mapper method 'org.lin.hms.dao.IndentDAO.insertIndent' has an unsupported return type: interface java.util.List
出现这种错误,说明sql语句执行成功,只是返回类型出了问题. 解决办法: mapper文件中的update,delete,insert语句是不需要设置返回类型的,它们都是默认返回一个int ,所以把返 ...
- java中的4种引用和GC Roots
https://juejin.im/post/5d06de9d51882559ee6f4212?utm_source=gold_browser_extension 1.首先,四种引用如下: Final ...
- C#实现控制台打印年历
C#实现控制台打印年历 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System. ...
- Python第十章实验报告
一.实验对象:<零基础学Python>6道实例和2道实战 二.实验环境:IDLE Shell 3.9.7 三.实验目的:学习如何在Python中进行文件和目录的相关操作 四.实验过程: 实 ...