19-10-26-F
ZJ一下:
T1码了暴力但是并没有开出来身高的神奇性质……
T2打模拟,但是只摸了卅分
T3不会,码了一个测试点分治。10分
TJ一下:
T1。
发现身高范围在$[140,200]$时,直接去重跑$\text{dp}$就行了。
时间复杂度:$\Theta(V^2)$($V$为值域大小)
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define N 111111
#define K 22
#define LF double using namespace std; int pn,qn;
LF arr[N],ans;
LF dp[N][K];
inline LF p2(LF k){
return k*k;
}
int main(){
// freopen("queue.in" ,"r",stdin);\
freopen("queue.out","w",stdout);
scanf("%d%d",&pn,&qn);
for(int i=1;i<=pn;i++)
scanf("%lf",arr+i);
sort(arr+1,arr+pn+1);
pn=unique(arr+1,arr+pn+1)-arr-1;
for(int i=1;i<=pn;i++)
for(int j=1;j<=qn;j++)
dp[i][j]=1e10;
for(int i=1;i<=pn;i++){
dp[i][1]=p2(arr[i]-arr[1]);
}
for(int i=2;i<=pn;i++){
for(int j=2;j<=qn;j++){
for(int k=i-1;k>=1;k--){
dp[i][j]=min(dp[i][j],dp[k][j-1]+p2(arr[i]-arr[k+1]));
}
}
}
ans=1e10;
for(int i=1;i<=qn;i++)
ans=min(ans,dp[pn][i]);
printf("%.2lf\n",ans);
} /*
140.59 168 170 180 199.99
*/
T2
模拟(竟然没改出来,遗憾死了……)
所以:
$$\Huge \sqcup$$
T3
采用法2。
类似抵制克苏恩?
设$f_{i,j,k,x}$为有$i$种球只剩一个,$j$种球只剩两个,$k$个球只剩三个,上次拿的球有$x$个(拿之前)
于是用记忆搜,转移并不费力。
因为没取模,于是码一个高精度。
不要用 __int128_t ! 不要用 __int128_t ! 不要用 __int128_t !
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define L 55
#define N 16 using namespace std; struct Hyper_long{
int A[L];
Hyper_long(){memset(A,0,sizeof A);A[0]=1;}
int length(){return A[0];}
void set_l(int len){this->A[0]=len;}
int &operator [](int id){
return A[id];
}
friend Hyper_long operator + (Hyper_long &a,Hyper_long &b){
Hyper_long c;
int len=max(a.length(),b.length()),r=0;
for(int i=1;i<=len;i++){
c[i]=a[i]+b[i]+r;//cout<<c[i]<<endl;
r=c[i]/10000;//cout<<r<<endl;
c[i]%=10000;//cout<<c[i]<<endl;
}
if(r){
len++;
c[len]=r;
}
c.set_l(len);
return c;
}
void out(){
printf("%d",A[A[0]]);;
for(int i=A[0]-1;i>0;i--)
printf("%04d",A[i]);
puts("");
}
}dp[N][N][N][N],_1;
bool m[N][N][N][N];
int cn,bn[N],pos[N];
Hyper_long operator * (Hyper_long a,int b){
Hyper_long c;
int len=a.length();
long long r=0;
for(int i=1;i<=len;i++){
c[i]=a[i]*b+r;
r=c[i]/10000;
c[i]%=10000;
}
while(r){
len++;
c[len]=r%10000;
r=c[len]/10000;
}
c.set_l(len);
return c;
}
void operator += (Hyper_long &a,Hyper_long b){a=a+b;}
Hyper_long dfs(int i,int j,int k,int las){
if((!i)&&(!j)&&(!k))return _1;
if(m[i][j][k][las])return dp[i][j][k][las];
Hyper_long ans;
if(i) ans+=dfs(i-1,j ,k ,1)*(i-(las==2));
if(j) ans+=dfs(i+1,j-1,k ,2)*(j-(las==3));
if(k) ans+=dfs(i ,j+1,k-1,3)*(k-(las==4));
m[i][j][k][las]=1;
return dp[i][j][k][las]=ans;
}
int main(){
cin.sync_with_stdio(false);
_1[0]=_1[1]=1;
cin>>cn;
for(int i=1;i<=cn;i++){
cin>>bn[i];
pos[bn[i]]++;
}
dfs(pos[1],pos[2],pos[3],6).out();
}
19-10-26-F的更多相关文章
- 2018.10.26 浪在ACM 集训队第二次测试赛
2018.10.26 浪在ACM 集训队第二次测试赛 整理人:苗学林 A海港 参考博客:[1]:李继朋https://www.cnblogs.com/violet-acmer/p/9859006.ht ...
- 程序员的 Ubuntu 19.10 配置与优化指南
原文地址:程序员的 Ubuntu 19.10 配置与优化指南 0x00 环境 CPU: Intel Core i9-9900k GPU: GeForce RTX 2070 SUPER RAM: DDR ...
- 背水一战 Windows 10 (26) - XAML: x:DeferLoadStrategy, x:Null
[源码下载] 背水一战 Windows 10 (26) - XAML: x:DeferLoadStrategy, x:Null 作者:webabcd 介绍背水一战 Windows 10 之 XAML ...
- forever start Error: Cannot find module './daemon.v0.10.26'
我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3590158.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...
- 2018.10.26 浪在ACM 集训队第四次测试赛
2018.10.26 浪在ACM 集训队第四次测试赛 题目一览表 来源 考察知识点 完成时间 A 生活大爆炸版 石头剪刀布 NOIP 提高组 2014 模拟??? 2018.11.9 B 联合 ...
- 欢迎来怼——第14次Scrum会议(10/26)
一.小组信息 队名:欢迎来怼小组成员队长:田继平成员:李圆圆,葛美义,王伟东,姜珊,邵朔,冉华 小组照片 二.开会信息 时间:2017/10/26 17:00~17:13(总计13min).地点:计 ...
- ubuntun 下安装 node-v0.10.26
sudo apt-get install g++ curl libssl-dev apache2-utils wget http://nodejs.org/dist/v0.10.26/node-v0. ...
- Ubuntu 19.10 发布 | 云原生生态周报 Vol. 24
作者 | 木苏.进超.冬岛.元毅.心水.衷源 业界要闻 1.云原生编程语言 Pulumi 1.0 pulumi ,一款中立的开源云开发平台,Pulumi 支持多语言.混合云环境.完全可扩展.初期支持 ...
- [Linux] 在 Ubuntu 19.10 上开启 SSH 服务并允许远程登录
在 Ubuntu 19.10 上安装 SSH,并开启服务 0.检查并确认系统当前是否已安装SSH: sudo ps -e | grep ssh 如果只有 ssh-agent 说明 ssh-server ...
- [Linux] 树莓派 4B 安装 Ubuntu 19.10 (Eoan Ermine) IOT 版
硬件:Raspberry Pi 4B系统:Ubuntu 19.10 (Eoan Ermine) for IOT官网:https://ubuntu.com/download/iot/raspberry- ...
随机推荐
- TopCoder[SRM513 DIV 1]:PerfectMemory(500)
Problem Statement You might have played the game called Memoria. In this game, there is a board ...
- MFC基础类及其层次结构
从类CCmdTarget派生出绝大多数MFC中的类,其层次结构如下图: 从根类Cobject层层派生出绝大多数MFC中的类,层次结构如下图: MFC中重点类: CObject类是MFC的绝大部分类的基 ...
- duilib教程之duilib入门简明教程8.完整的自绘标题栏
看了前面那么多教程,相信对duilib已有基本映像了,我们就快马加鞭,做出一个完整的自绘标题栏吧~ 看到下面这个效果图,小伙伴们是不是有点惊呆了呢~O(∩_∩)O~ duilib实现以 ...
- duilib教程之duilib入门简明教程6.XML配置界面
前面那些教程都是为了让小伙伴们从win32.MFC过渡到duilib,让大家觉得duilib不是那么陌生,如果大家现在还对duilib非常陌生的话,那就说明前面的教程做得不好,请大家在下面留言,我会一 ...
- 自定义Collection View布局
转自answer-huang的博客 原文出自:Custom Collection View Layouts UICollectionView在iOS6中第一次被介绍,也是UIKit视图类中的一颗 ...
- hexo next主题中遇到的关于require的timeout的问题。Uncaught Error: Load timeout for modules:
个人博客:https://mmmmmm.me 源码:https://github.com/dataiyangu/dataiyangu.github.io 背景 报错:Uncaught Error: L ...
- Java学习之创建对象内存使用机制
Java内存空间分两种,一种是栈内存,有多个,一种是堆内存,只有一个,在堆内存中又有一块方法区. 方法区中存储的是:类的信息(类名,类的直接父类,类的访问修饰符),类变量,类方法代码,实例方法代码,常 ...
- django汉化
汉化admin后台管理站点 修改settings文件(将上表格内容改变为下表格): LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' LANGUAGE_CODE = ...
- mysql初次使用
- docker上安装ActiveMQ
1.查看是否已经存在镜像 docker images 2.搜索镜像 docker search activemq 3.拉取镜像 docker pull webcenter/activemq 4.构建容 ...