2017ACM/ICPC广西邀请赛-重现赛(感谢广西大学)
上一场CF打到心态爆炸,这几天也没啥想干的
A Math Problem
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0
Each case only contains a positivse integer n in a line.
1≤n≤1018
4
2
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=;
int main()
{
ll n;
while(~scanf("%lld",&n))
{
if(n>=N)
printf("15\n");
else
{
for(int k=; k<; k++)
{
ll s=;
for(int i=; i<k; i++)
s*=k;
if(s>n)
{
printf("%d\n",k-);
break;
}
}
}
}
return ;
}
Covering
Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0
To protect boys and girls from getting hurt when playing happily on the playground, rich boy Bob decided to cover the playground using his carpets.
Meanwhile, Bob is a mean boy, so he acquired that his carpets can not overlap one cell twice or more.
He has infinite carpets with sizes of 1×2 and 2×1, and the size of the playground is 4×n.
Can you tell Bob the total number of schemes where the carpets can cover the playground completely without overlapping?
Each test case only contains one positive integer n in a line.
1≤n≤1018
2
5
a[n]=a[n-1]+5*a[n-2]+a[n-3]-a[n-4];
#include <stdio.h>
#include <string.h>
const int MD=1e9+;
typedef long long LL;
struct matrix
{
LL mat[][];
};
matrix matmul(matrix a,matrix b,int n)
{
int i,j,k;
matrix c;
memset(c.mat,,sizeof(c.mat));
for(i=; i<n; i++)
{
for(j=; j<n; j++)
{
for(k=; k<n; k++)
{
c.mat[i][j]=(c.mat[i][j]+a.mat[i][k]*b.mat[k][j])%MD;
}
}
}
return c;
}
matrix matpow(matrix a,LL k,int n)
{
matrix b;
int i;
memset(b.mat,,sizeof(b.mat));
for(i=; i<n; i++) b.mat[i][i]=;
while(k)
{
if(k&) b=matmul(a,b,n);
a=matmul(a,a,n);
k>>=;
}
return b;
}
int main()
{
LL k;
matrix a,b;
memset(a.mat,,sizeof(a.mat));
memset(b.mat,,sizeof(b.mat));
a.mat[][]=,a.mat[][]=,a.mat[][]=;
b.mat[][]=,b.mat[][]=,b.mat[][]=,b.mat[][]=-;
b.mat[][]=,b.mat[][]=,b.mat[][]=;
while(~scanf("%lld",&k))
{
printf("%lld\n",(matmul(matpow(b,k,),a,).mat[][]+MD)%MD);
}
return ;
}
CS Course
Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0
Today he has learned bit-operations in Algorithm Lessons, and he got a problem as homework.
Here is the problem:
You are giving n non-negative integers a1,a2,⋯,an, and some queries.
A query only contains a positive integer p, which means you 
are asked to answer the result of bit-operations (and, or, xor) of all the integers except ap.
Each test case begins with two positive integers n and p
in a line, indicate the number of positive integers and the number of queries.
2≤n,q≤105
Then n non-negative integers a1,a2,⋯,an follows in a line, 0≤ai≤109 for each i in range[1,n].
After that there are q positive integers p1,p2,⋯,pqin q lines, 1≤pi≤n for each i in range[1,q].
1 1 1
1
2
3
1 1 0
1 1 0
异或最简单,再异或一次就好了
所以按位存储了
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+;
int a[N],b[N];
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
memset(b,,sizeof(b));
int Xor=,And=0xffffffff,Or=;
for(int i=; i<=n; i++)
{
int x;
scanf("%d",&x);
a[i]=x;
And&=x;
Or|=x;
Xor^=x;
for(int j=; x; j++,x>>=)
b[j]+=x%;
}
while(m--)
{
int q;
scanf("%d",&q);
q=a[q];
int A=And,O=Or,X=Xor;
X=X^q;
for(int j=; j<=; j++,q>>=)
{
if(b[j]==n-&&q%==)A+=(<<j);
if(b[j]==&&q%)O-=(<<j);
}
printf("%d %d %d\n",A,O,X);
}
}
return
Duizi and Shunzi
Now give you n integers, ai(1≤i≤n)ai(1≤i≤n)
We define two identical numbers (eg: 2,22,2) a Duizi, 
and three consecutive positive integers (eg: 2,3,42,3,4) a Shunzi.
Now you want to use these integers to form Shunzi and Duizi as many as possible.
Let s be the total number of the Shunzi and the Duizi you formed.
Try to calculate max(s)max(s).
Each number can be used only once.
InputThe input contains several test cases.
For each test case, the first line contains one integer n(1≤n≤1061≤n≤106). 
Then the next line contains n space-separated integers aiai (1≤ai≤n1≤ai≤n) 
OutputFor each test case, output the answer in a line. 
Sample Input
7
1 2 3 4 5 6 7
9
1 1 1 2 2 2 3 3 3
6
2 2 3 3 3 3
6
1 2 3 3 4 5
Sample Output
2
4
3
2
Hint
Case 1(1,2,3)(4,5,6) Case 2(1,2,3)(1,1)(2,2)(3,3) Case 3(2,2)(3,3)(3,3) Case 4(1,2,3)(3,4,5)
这个题看起来很简单,问你最多可形成多少个对子和顺子
可是有坑啊,可以按照对子打,也可以按照顺子打,我当然按照对子打了,但是按照对子打可能我的顺子就没了,所以我首先是要打足够多的牌
比如我往下贪心的时候,如果第二张恰好是对子,我贪心就亏了,但是我下一张正好三张我肯定就要了这个顺子
所以就是记录顺子和找对子了
#include <stdio.h>
#include <string.h>
const int N=1e5+;
int a[N];
int main()
{
int n;
while(~scanf("%d",&n))
{
memset(a,,sizeof(int)*(n+));
for(int i=; i<n; i++)
{
int x;
scanf("%d",&x);
a[x]++;
}
int ans=;
for(int i=; i<n-; i++)
{
ans+=a[i]/;
if(a[i]&&&a[i+]&&&a[i+])
{
ans++;
a[i+]--;
a[i+]--;
}
}
ans+=a[n-]/+a[n]/;
printf("%d\n",ans);
}
return ;
}
2017ACM/ICPC广西邀请赛-重现赛(感谢广西大学)的更多相关文章
- 2017ACM/ICPC广西邀请赛-重现赛 1007.Duizi and Shunzi
		
Problem Description Nike likes playing cards and makes a problem of it. Now give you n integers, ai( ...
 - 2017ACM/ICPC广西邀请赛-重现赛 1010.Query on A Tree
		
Problem Description Monkey A lives on a tree, he always plays on this tree. One day, monkey A learne ...
 - 2017ACM/ICPC广西邀请赛-重现赛 1004.Covering
		
Problem Description Bob's school has a big playground, boys and girls always play games here after s ...
 - 2017ACM/ICPC广西邀请赛-重现赛
		
HDU 6188 Duizi and Shunzi 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6188 思路: 签到题,以前写的. 实现代码: #inc ...
 - 2017ACM/ICPC广西邀请赛-重现赛 1001 A Math Problem
		
2017-08-31 16:48:00 writer:pprp 这个题比较容易,我用的是快速幂 写了一次就过了 题目如下: A Math Problem Time Limit: 2000/1000 M ...
 - 2017ACM/ICPC广西邀请赛-重现赛1005 CS course
		
2017-08-31 16:19:30 writer:pprp 这道题快要卡死我了,队友已经告诉我思路了,但是做题速度很缓慢,很费力,想必是因为之前 的训练都是面向题解编程的缘故吧,以后不能这样了,另 ...
 - HDU 6191 2017ACM/ICPC广西邀请赛 J Query on A Tree 可持久化01字典树+dfs序
		
题意 给一颗\(n\)个节点的带点权的树,以\(1\)为根节点,\(q\)次询问,每次询问给出2个数\(u\),\(x\),求\(u\)的子树中的点上的值与\(x\)异或的值最大为多少 分析 先dfs ...
 - 2017ACM/ICPC广西邀请赛
		
A.A Math Problem #include <bits/stdc++.h> using namespace std; typedef long long ll; inline ll ...
 - 2017ACM/ICPC广西邀请赛 Duizi and Shunzi
		
题意:就是一个集合分开,有两种区分 对子:两个相同数字,顺子:连续三个不同数字,问最多分多少个 解法:贪心,如果当前数字不构成顺子就取对子 /2,如果可以取顺子,那么先取顺子再取对子 #include ...
 
随机推荐
- React-redux及异步获取数据20分钟快速入门
			
一, 写在前面 1. 前面我写过一个vuex10分钟入门 传送门 2. React-redux网上有好多文档,又臭又长,明明很简单的问题,硬是让新人更晕了~, 我写这个文章的目的是让新人在20分钟之内 ...
 - mybatis实现使用原生的sql
			
1.相应的xml文件中 <select id="selectByCategories" resultType="map" parameterType=&q ...
 - [windows]win7设置wifi热点
			
1.启用并设定虚拟WiFi网卡:netsh wlan set hostednetwork mode=allow ssid=whylaughing key=124025621 2.开启无线wifi网络: ...
 - 总结SQL Server窗口函数的简单使用
			
总结SQL Server窗口函数的简单使用 前言:我一直十分喜欢使用SQL Server2005/2008的窗口函数,排名函数ROW_NUMBER()尤甚.今天晚上我在查看SQL Server开发的相 ...
 - 在前台引用JSON对象
			
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script&g ...
 - 51nod 1526 分配笔名
			
题目来源: CodeForces 基准时间限制:1 秒 空间限制:131072 KB 分值: 320 难度:7级算法题. 班里有n个同学.老师为他们选了n个笔名.现在要把这些笔名分配给每一个同学,每一 ...
 - WebStorm 配置less
			
1.打开Webstorm的Setting 搜索,watch 找到 File watch,点击右侧加号添加Less. 2.配置, working directory. Output paths
 - HDOJ1195 双向BFS //单向也可以过 没想清
			
#include<cstdio> #include<map> #include<vector> #include<stack> #include< ...
 - (五)使用Docker镜像(上)
			
1. 获取镜像 # 获取镜像 docker pull image:tag // 不使用tag 默认下载latest标签的镜像,即最新的镜像. 2. 查看镜像信息 # 查看镜像信息docker imag ...
 - FIBON高精度
			
#include<stdio.h> #include<string.h> int u,n; ],b[],h[]; ],y[],z[]; int main() { char s( ...