湖南大学第十四届ACM程序设计新生杯(重现赛)
RANK 0 题数 0
期末复习没有参加,补几道喜欢的题。
A: AFei Loves Magic 签到
思路 :不需考虑 碰撞 直接计算最终状态即可。
#include<bits/stdc++.h>
using namespace std;
#define maxn 12345
int ans,n,l,t,x,d;
int main()
{
scanf("%d%d%d",&n,&l,&t);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&x,&d);
if(d==1)
if(x+t<l)ans++;
if(d==2)
if(x-t>0)ans++;
}
printf("%d\n",ans+1);
return 0;
}
D: Dandan's lunch
叉积计算 三角形面积,没有给定点的顺序需要取绝对值。
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 123456
struct node
{
ll x[5],y[5],sum;
bool operator<(const node &b)const
{
return sum>b.sum;
}
} a[maxn];
void cal(int id)
{
ll s1=0,s2=0;
for(int i=1; i<=3; i++)
{
s1+=a[id].x[i]*a[id].y[i+1];
s2+=a[id].x[i+1]*a[id].y[i];
}
a[id].sum=fabs(s1-s2);
}
ll n,rk,cp,one;
int main()
{
rk=0;
scanf("%lld",&n);
for(int i=0; i<n; i++)
{
scanf("%lld",&cp);
if(i==0)one=cp;
else
{
if(cp>one)rk++;
}
for(int j=1; j<=3; j++)
scanf("%lld%lld",&a[i].x[j],&a[i].y[j]);
a[i].x[4]=a[i].x[1];
a[i].y[4]=a[i].y[1];
cal(i);
}
sort(a,a+n);
printf("%lld\n",a[rk].sum);
return 0;
}
F:Find the AFei Numbers
裸数位DP根据自己喜欢的方式定合理dp状态。
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 1324
ll t,n,dp[23][2][2][2];
int num[25],id;
ll dfs(int cnt,bool is520,bool is52,bool is5,bool limit)
{
if(cnt==0)return is520?1:0;
if(!limit&&dp[cnt][is520][is52][is5]!=-1)
return dp[cnt][is520][is52][is5];
ll sum=0,up=(limit?num[cnt]:9);
for(int i=0; i<=up; i++)
{
if(is520)
sum+=dfs(cnt-1,1,0,0,(limit&&i==up));
else if(is52&&i==0)
sum+=dfs(cnt-1,1,0,0,(limit&&i==up));
else if(is5&&i==2)
sum+=dfs(cnt-1,0,1,0,(limit&&i==up));
else if(i==5)
sum+=dfs(cnt-1,0,0,1,(limit&&i==up));
else
sum+=dfs(cnt-1,0,0,0,(limit&&i==up));
}
if(!limit)dp[cnt][is520][is52][is5]=sum;
return sum;
}
ll solve()
{
id=0;
while(n)
{
num[++id]=n%10;
n/=10;
}
return dfs(id,0,0,0,1);
}
int main()
{
scanf("%lld",&t);
while(t--)
{
memset(dp,-1,sizeof(dp));
scanf("%lld",&n);
printf("%lld\n",solve());
}
return 0;
}
L:The Digits String
思路 :dp[ n ] [ 4 ] 代表长度为 n时 取余4为0 的方案数 ,取余4为1的方案数 ,取余4为2的方案数 ,取余4为3的方案数。
根据每次数字增加一个长度 的种类 只有 10种 0 - 9 很容易写出递推方程 ,由于 n较大 ,矩阵快速幂加速即可。
#include<bits/stdc++.h>
using namespace std;
#define maxn 123456
#define ll long long
#define mod 2019
struct node
{
ll a[10][10];
void up1()
{
for(int i=0; i<5; i++)
for(int j=0; j<=5; j++)
if(i==j)a[i][j]=1;
else a[i][j]=0;
}
void up2()
{
for(int i=0; i<5; i++)
for(int j=0; j<=5; j++)
a[i][j]=0;
}
} mat,one,mtt;
ll n,ans;
node p(node xx,node yy)
{
node cc;
cc.up2();
for(int k=1; k<=4; k++)
for(int i=1; i<=4; i++)
for(int j=1; j<=4; j++)
cc.a[i][j]=(cc.a[i][j]+(xx.a[i][k]*yy.a[k][j])%mod)%mod;
return cc;
}
node qpow(ll b)
{
node ret;
ret.up1();
while(b)
{
if(b%2)
ret=p(ret,mat);
mat=p(mat,mat);
b/=2;
}
return ret;
}
int main()
{
one.a[1][1]=3,one.a[2][1]=2,one.a[3][1]=2,one.a[4][1]=3;
one.a[1][2]=3,one.a[2][2]=3,one.a[3][2]=2,one.a[4][2]=2;
one.a[1][3]=2,one.a[2][3]=3,one.a[3][3]=3,one.a[4][3]=2;
one.a[1][4]=2,one.a[2][4]=2,one.a[3][4]=3,one.a[4][4]=3;
while(~scanf("%lld",&n))
{
mat=one;
mtt=qpow(n-1);
ans=3*mtt.a[1][1]+3*mtt.a[2][1]+2*mtt.a[3][1]+2*mtt.a[4][1];
ans%=mod;
printf("%lld\n",ans);
}
return 0;
}
湖南大学第十四届ACM程序设计新生杯(重现赛)的更多相关文章
- 湖南大学第十四届ACM程序设计新生杯(重现赛)G a+b+c+d=? (16进制与LL范围)
链接:https://ac.nowcoder.com/acm/contest/338/G来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K6 ...
- 湖南大学第十四届ACM程序设计新生杯(重现赛)I:II play with GG(博弈论||DP)
链接:https://ac.nowcoder.com/acm/contest/338/I 来源:牛客网 题目描述 IG won the S championship and many people a ...
- 湖南大学第十四届ACM程序设计新生杯 E.Easy Problem
E.Easy Problem Description: Zghh likes number, but he doesn't like writing problem description. So h ...
- 湖南大学第十四届ACM程序设计新生杯 Dandan's lunch
Dandan's lunch Description: As everyone knows, there are now n people participating in the competiti ...
- 福建工程学院第十四届ACM程序设计大赛 - E - 外传:小晋逃生记
http://www.fjutacm.com/Contest.jsp?cid=705#P4 其实想清楚了就很简单,之前想了很多种方法,以为是二分什么的,看起来就像是一个单峰函数.但是发现直接暴力一波就 ...
- 福建工程学院第十四届ACM校赛M题题解 fwt进阶,手推三进制fwt
第九集,结束亦是开始 题意: 大致意思就是给你n个3进制的数字,让你计算有多少对数字的哈夫曼距离等于i(0<=i<=2^m) 思路: 这个是一个防ak题,做法是要手推公式的fwt 大概就这 ...
- 湖南大学ACM程序设计新生杯大赛(同步赛)J - Piglet treasure hunt Series 2
题目描述 Once there was a pig, which was very fond of treasure hunting. One day, when it woke up, it fou ...
- 湖南大学ACM程序设计新生杯大赛(同步赛)A - Array
题目描述 Given an array A with length n a[1],a[2],...,a[n] where a[i] (1<=i<=n) is positive integ ...
- 湖南大学ACM程序设计新生杯大赛(同步赛)L - Liao Han
题目描述 Small koala special love LiaoHan (of course is very handsome boys), one day she saw N (N<1e1 ...
随机推荐
- linux 基础知识(三)
抽空把Linux的一些基础的东西再补充一下,安全的东西真的很多都是要自己不断的学习,很多还是今天学习了一点时间过后不用就会忘记.所以学习的东西就是要不断地往复. 有时候感觉有时候快就是慢,慢就是快. ...
- (转)一位资深程序员大牛给予Java初学者的学习路线建议
Java学习这一部分其实也算是今天的重点,这一部分用来回答很多群里的朋友所问过的问题,那就是你是如何学习Java的,能不能给点建议?今天我是打算来点干货,因此咱们就不说一些学习方法和技巧了,直接来谈每 ...
- Jenkins删除或替换All view
一.Jenkins删除All view “系统管理”→“系统设置”页面,更改“Default view”的下拉选项.(前提你已经新建了新的view) 二.My Views删除All view “用户” ...
- The.Glory.of.Innovation 创新之路3放飞好奇
教育最重要的就是 问题不在于教他各种学问,而在于培养他爱好学问的兴趣,而且在这种兴趣充分增长起来的时候,教他以研究学问的方法. ———— 卢梭 如何辨识不同的观点, 老师考查的重点不在于学生 ...
- openstack 基础
一:openstack起源: 1.rackspace和NASA(美国国家航空航天局)共同发起的开源项目 1.1/rackspace:贡献的swaft子项目(存储组件) 1.2/NASA:贡献了nova ...
- gulp构建自动化项目
'use strict'; var gulp = require('gulp'), browserSync = require('browser-sync').create(), SSI = requ ...
- STL容器之优先队列
STL容器之优先队列 优先级队列,以前刷题的时候用的比较熟,现在竟然我只能记得它的关键字是priority_queue(太伤了).在一些定义了权重的地方这个数据结构是很有用的. 先回顾队列的定义:队列 ...
- K3 WISE 开发插件《SQL语句WHERE查询-范围查询/模糊查询》
0.存储过程开头变量定义 @FBeginDate varchar(10), --单据起始日期 @FEndDate varchar(10), --单据截止日期. @FItemID varchar(50) ...
- 647. Palindromic Substrings
Given a string, your task is to count how many palindromic substrings in this string. The substrings ...
- Redis的搭建和Redis的集群搭建
1.Redis的官网:https://redis.io/ Redis的测试网站:http://try.redis.io/ 2.参考博客:https://www.cnblogs.com/maf ...