湖南大学第十四届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 ...
随机推荐
- ActiveMQ消息的持久化策略
持久化消息和非持久化消息的存储原理: 正常情况下,非持久化消息是存储在内存中的,持久化消息是存储在文件中的.能够存储的最大消息数据在${ActiveMQ_HOME}/conf/activemq.xml ...
- 关于C++ const 的全面总结 (转)
C++中的const关键字的用法非常灵活,而使用const将大大改善程序的健壮性,本人根据各方面查到的资料进行总结如下,期望对朋友们有所帮助. Const 是C++中常用的类型修饰符,常类型是指使用类 ...
- spring cloud 自定义ribbon客户端
一.自定义Ribbon客户端-[方式一]配置类 1.1.自定义负载规则 增加RibbonConfiguration.java配置类 public class RibbonConfiguration { ...
- 如何让谷歌浏览器支持跨域访问(AJAX) AJAX调试跨域接口
以谷歌最新版本为例(2018) 1.在电脑上新建一个目录,例如:C:\MyChromeDevUserData 2.在属性页面中的目标输入框里加上 --disable-web-security -- ...
- WBXML 1.3协议摘要
协议地址:WAP195 网络字节顺序:big-endian. 为什么要加0x40? 参考:Compressing XML When an element contains content (t ...
- 步步为营-104-Lambda语句
1:Lambda的拼接 首先借助一个Lambda的帮助类 using System; using System.Collections.Generic; using System.Linq; usin ...
- IOU和非极大值抑制
如何判断对象检测算法运作良好呢? 一.交并比(Intersection over union,IoU) 是产生的候选框(candidate bound)与原标记框(ground truth bound ...
- angular 4 开发环境下打包文件过大
angular 4本地开发环境下,ng server -- port 8080 -o 之后在在浏览器中查看数据请求,其中vendor.bundle.js有8.3mb,而整个传输数据大小为16.3mb ...
- element-ui MessageBox的bug
通过 use引用messageBox有bug Vue.use(MessageBox) 页面一开始会有一个弹窗,内容空白 Vue.component(MessageBox.name, MessageBo ...
- Morley's Theorem
题解: 计算几何基本操作 注意叉积的时候字母写的顺序 代码: #include <bits/stdc++.h> using namespace std; #define rint regi ...