湖南大学第十四届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 ...
随机推荐
- python自动化-unittest批量执行用例(discover)
前言 我们在写用例的时候,单个脚本的用例好执行,那么多个脚本的时候,如何批量执行呢?这时候就需要用到unittet里面的discover方法来加载用例了. 加载用例后,用unittest里面的Text ...
- ubuntu MySQL的安装
https://i.cnblogs.com/EditPosts.aspx?opt=1 https://juejin.im/entry/5adb5deff265da0b9d77cb3b MySQL Co ...
- 三维拓扑排序好题hdu3231
/* 三维拓扑排序 将每个长方体分解成六个面,xyz三维进行操作 每一维上的的所有长方体的面都应该服从拓扑关系,即能够完成拓扑排序=如果两个长方体的关系时相交,那么其对应的三对面只要交叉即可 如 a1 ...
- hdu4966 最小树形图+虚根
/* 辛辛苦苦调试半天, 过了样例,竟然没有ac!! 网上对比了ac代码,感觉添加一个虚根就能ac 但是想不明白为什么 */ /* 第二天想了下,知道了为什么wa:因为从等级0连到其他课程等级i的不止 ...
- java web 项目中 简单定时器实现 Timer
java web 项目中 简单定时器实现 Timer 标签: Java定时器 2016-01-14 17:28 7070人阅读 评论(0) 收藏 举报 分类: JAVA(24) 版权声明:本文为博 ...
- jmeter 中如何一次运行多条sql语句
在jmeter测试mysql中如何一次运行多条sql语句 allowMultiQueries=true 注意:太低版本的mysql和jdbc不支持,最好用最新版的
- AI-CBV写法
AI-CBV写法 CBV固定样式 #url.py from django.conf.urls import url from django.contrib import admin from app0 ...
- OpenCV-Python教程8-图像混合
一.图片相加 要叠加两张图片,使用cv2.add(),相加两幅图片的形状(高度.宽度.通道数)必须相同.numpy中可以直接用res = img1 + img2相加.但是两者的结果并不相同 impor ...
- 新版的K8S中的flannel.yaml文件中要注意的细节
部署flannel作为k8s中的网络插件,yaml文件都大小同异. 但在要注意以下细节. 以前,只需要前面master判断. 现在也需要有not-ready状态了. tolerations: - ke ...
- noi.ac 第五场第六场
t1应该比较水所以我都没看 感觉从思路上来说都不难(比牛客网这可简单多了吧) 第五场 t2: 比较套路的dp f[i]表示考虑前i个数,第i个满足f[i]=i的最大个数 i能从j转移需要满足 j< ...