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程序设计新生杯(重现赛)的更多相关文章

  1. 湖南大学第十四届ACM程序设计新生杯(重现赛)G a+b+c+d=? (16进制与LL范围)

    链接:https://ac.nowcoder.com/acm/contest/338/G来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K6 ...

  2. 湖南大学第十四届ACM程序设计新生杯(重现赛)I:II play with GG(博弈论||DP)

    链接:https://ac.nowcoder.com/acm/contest/338/I 来源:牛客网 题目描述 IG won the S championship and many people a ...

  3. 湖南大学第十四届ACM程序设计新生杯 E.Easy Problem

    E.Easy Problem Description: Zghh likes number, but he doesn't like writing problem description. So h ...

  4. 湖南大学第十四届ACM程序设计新生杯 Dandan's lunch

    Dandan's lunch Description: As everyone knows, there are now n people participating in the competiti ...

  5. 福建工程学院第十四届ACM程序设计大赛 - E - 外传:小晋逃生记

    http://www.fjutacm.com/Contest.jsp?cid=705#P4 其实想清楚了就很简单,之前想了很多种方法,以为是二分什么的,看起来就像是一个单峰函数.但是发现直接暴力一波就 ...

  6. 福建工程学院第十四届ACM校赛M题题解 fwt进阶,手推三进制fwt

    第九集,结束亦是开始 题意: 大致意思就是给你n个3进制的数字,让你计算有多少对数字的哈夫曼距离等于i(0<=i<=2^m) 思路: 这个是一个防ak题,做法是要手推公式的fwt 大概就这 ...

  7. 湖南大学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 ...

  8. 湖南大学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 ...

  9. 湖南大学ACM程序设计新生杯大赛(同步赛)L - Liao Han

    题目描述 Small koala special love LiaoHan (of course is very handsome boys), one day she saw N (N<1e1 ...

随机推荐

  1. django模板导入外部js和css等文件

    1.新建文件夹templates(存放模板文件),新建文件夹media(存放js.css.images文件夹),并把两个文件夹放到了项目的根目录下 2.设定模板路径 设置模板路径比较简单,只要在set ...

  2. LeetCode(115):不同的子序列

    Hard! 题目描述: 给定一个字符串 S 和一个字符串 T,计算在 S 的子序列中 T 出现的个数. 一个字符串的一个子序列是指,通过删除一些(也可以不删除)字符且不干扰剩余字符相对位置所组成的新字 ...

  3. matlab提取wind底层数据库操作

    首先需要安装navicat for SQL server 软件, 为了实现Matlab 通过JDBC方式连接Sqlserver数据库, 需要安装Sqlserver JDBC驱动. 地址: https: ...

  4. jQuery 常用的方法

    <!DOCTYPE html><html lang="en"><head> <meta charset="utf-8" ...

  5. 滴水穿石-08IO

    1.0 File a:构造方法 package d8; import java.io.File; public class FileGouZao { public static void main(S ...

  6. linux dig 命令使用方法

    ref:https://www.imooc.com/article/26971?block_id=tuijian_wz dig 命令主要用来从 DNS 域名服务器查询主机地址信息. 查询单个域名的 D ...

  7. 学习笔记: 反射应用、原理,完成扩展,emit动态代码

    using Ruanmou.DB.Interface; using Ruanmou.DB.MySql; using Ruanmou.DB.SqlServer; using Ruanmou.Model; ...

  8. 【演示】在CSS里用calc进行计算

    请阅读 在CSS里用calc进行计算   下面的元素的width,padding,margin都使用了CSS calc进行计算. 简单计算: 100% – 100px 这是经过简单计算的元素宽度 复杂 ...

  9. 014 Security的认证流程源码级详解

    一:任务 1.任务 认证处理流程说明 认证结果如何在多个请求之间共享 获取认证用户信息 二:认证处理流程处理说明 1.流程图 这里只是一个登陆到登陆的认证部分的流程图. 2.流程解释 3.断点跟踪 页 ...

  10. Python多继承之MRO算法

    MRO即Method Resolution Order   方法解析顺序,它的提出主要是为了解决Python中多继承时,当父类存在同名函数时,二义性的问题 下面先看一个例子: import inspe ...