湖南大学第十四届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 ...
随机推荐
- 关于Sublime text 3如何编辑less并转(编译)成css文件
今天开始学习使用less这个强大方便的前端工具,本来是考虑用koala(专门编辑less的软件)来使用less的,但是发现sublime编辑器也可以实现对less的编译及高亮显示代码,这样既能少用一个 ...
- Mycat实现mysql主从复制(读写分离)
数据库性能瓶颈主要原因: 随着用户数的增多,带来的是数据库连接的大幅度增长 随着业务体量的增长,表数据量(空间存储的问题)的大幅增长,其中涉及到索引的优化,mysql默认的索引是硬盘级别的,BTREE ...
- eclipse maven .jar中没有主清单属性
报错环境: windows系统eclipse maven 打包jar包后, 运行 java -jar 报错 E:\My_java\mysql\target>java -jar original- ...
- 单例、异常、eval函数
一.单例 01. 单例设计模式 设计模式 设计模式 是 前人工作的总结和提炼,通常,被人们广泛流传的设计模式都是针对 某一特定问题 的成熟的解决方案 使用 设计模式 是为了可重用代码.让代码更容易被他 ...
- antDesign 使用Form并进行表单验证
import React from 'react'; import {Form,Input,Select,Button ...} from 'antd'; class PageName extends ...
- Vue 导入文件import、路径@和.的区别
***import: html文件中,通过script标签引入js文件.而vue中,通过import xxx from xxx路径的方式导入文件,不光可以导入js文件. from前的:“xxx”指的是 ...
- vue项目中 axios 和Vue-axios的关系
文章收集于:https://segmentfault.com/q/1010000010812113 在vue项目中,会经常看到如下代码: 今天看到有些项目是这样写的,就有点看不懂了. ----解 ...
- python中深拷贝与浅拷贝
# 1.浅拷贝(复制东西)a = [11,22,33] # 实际上是浅拷贝# 没有把这个变量的值赋进去,而是把另一个变量的地址拿过去了,就叫浅拷贝.b = a # print(id(a))# prin ...
- SpringMVC之使用ResponseEntity,java接口返回HttpStatus
Post请求 一般情况下,在非必须的情况下,使用Jquery实现post请求,而后台返回一般都需要手动封装ResponseUtil,和使用@ResponseBody注解来实现返回.然而我们书上学到的关 ...
- 手机网页制作教程META标签你知道多少?【转+加】
一.天猫 <title>天猫触屏版</title> <meta content="text/html; charset=utf-8" http-equ ...