NOIP模拟赛9
T1U3348 A2-回文数
https://www.luogu.org/problem/show?pid=U3348
考场上钻了牛角尖了,然后0分
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long LL;
LL cnt[];
int ans[];
int main()
{
LL n;
scanf("%lld",&n);
LL now=;
int len;
for(len=;;len++)
{
if(n>now) n-=now;
else break;
if(len%==) now*=;
}
int i=len+>>;
n--;
LL tmp=;
for(int j=;j<i;j++) tmp*=;
for(int j=;j<i;j++)
{
for(int k=(j==);k<=;k++)
{
if(j== && k==) ans[j]=;
if(n>=tmp) ans[j]++,n-=tmp;
else break;
}
tmp/=;
}
for(int j=;j<i;j++) printf("%d",ans[j]);
printf("%d",n);
if(len%==) printf("%d",n);
for(int j=i-;j;j--) printf("%d",ans[j]);
}
T2[USACO08OPEN]农场危机Crisis on the Farm
https://www.luogu.org/problem/show?pid=2905
dp[k][i][j] 一共移动k次,其中东西方向i次,南北方向j次
东西:起始位置加减i
南北:起始位置加减j
最后倒退方案即可
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 1001
using namespace std;
int sx[N],sy[N],bx[N],by[N];
int f[][][],cnt[][];
char s[][][];
int dx[]={,,,-};
int dy[]={,,-,};
char c[]={'E','N','S','W'};
int main()
{ int n,m,k;
scanf("%d%d%d",&n,&m,&k);
for(int i=;i<=n;i++) scanf("%d%d",&sx[i],&sy[i]);
for(int i=;i<=m;i++) scanf("%d%d",&bx[i],&by[i]);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
if(abs(bx[j]-sx[i])+abs(by[j]-sy[i])<=k) cnt[bx[j]-sx[i]+k][by[j]-sy[i]+k]++;
memset(f,-,sizeof(f));
f[][k][k]=;
for(int h=;h<=k;h++)
for(int i=;i<=*k;i++)
for(int j=;j<=*k;j++)
if(abs(i-k)+abs(j-k)<=h)
f[h][i][j]=cnt[i][j]+max(max(f[h-][i-][j],f[h-][i+][j]),max(f[h-][i][j-],f[h-][i][j+]));
int ans=-;
for(int i=;i<=*k;i++)
for(int j=;j<=*k;j++)
ans=max(ans,f[k][i][j]);
for(int i=;i<=*k;i++)
for(int j=;j<=*k;j++)
if(f[k][i][j]==ans) s[k][i][j]='Z';
for(int h=k-;h>=;h--)
for(int i=;i<=*k;i++)
for(int j=;j<=*k;j++)
if(abs(i-k)+abs(j-k)<=h)
for(int l=;l<;l++)
if(s[h+][i+dx[l]][j+dy[l]] && f[h][i][j]+cnt[i+dx[l]][j+dy[l]]==f[h+][i+dx[l]][j+dy[l]])
{ s[h][i][j]=c[l]; break; }
printf("%d\n",ans);
int x=k,y=k;
for(int h=;h<k;h++)
{
putchar(s[h][x][y]);
for(int l=;l<;l++)
if(s[h][x][y]==c[l])
{
x+=dx[l]; y+=dy[l];
break;
}
}
}
T3[USACO07DEC]观光奶牛Sightseeing Cows
https://daniu.luogu.org/problem/show?pid=2868
分数规划+spfa判环
#include<cstdio>
#include<queue>
#include<cmath>
#include<cstring>
#define N 1001
#define M 5001
using namespace std;
int happy[N],cnt[N],n;
int front[N],to[M],nxt[M],val[M],tot;
double dis[N];
bool vis[N];
void add(int u,int v,int w)
{
to[++tot]=v; nxt[tot]=front[u]; front[u]=tot; val[tot]=w;
}
bool spfa(double m)
{
for(int i=1;i<=n;i++) dis[i]=2e9;
memset(vis,false,sizeof(vis));
memset(cnt,0,sizeof(cnt));
queue<int>q;
vis[1]=true;
dis[1]=0;
q.push(1);
int now;
while(!q.empty())
{
now=q.front();
q.pop(); vis[now]=false;
for(int i=front[now];i;i=nxt[i])
if(dis[to[i]]>dis[now]+m*val[i]-happy[to[i]])
{
dis[to[i]]=dis[now]+m*val[i]-happy[to[i]];
if(!vis[to[i]])
{
vis[to[i]]=true;
q.push(to[i]);
cnt[to[i]]++;
if(cnt[to[i]]>n) return true;
}
}
}
return false;
}
int main()
{
int p;
scanf("%d%d",&n,&p);
for(int i=1;i<=n;i++) scanf("%d",&happy[i]);
int u,v,w;
while(p--)
{
scanf("%d%d%d",&u,&v,&w);
add(u,v,w);
}
double l,r=1000,mid;
while(fabs(l-r)>1e-3)
{
mid=(l+r)/2;
if(spfa(mid)) l=mid;
else r=mid;
}
printf("%.2lf",l);
}
NOIP模拟赛9的更多相关文章
- NOIP模拟赛20161022
NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...
- contesthunter暑假NOIP模拟赛第一场题解
contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...
- NOIP模拟赛 by hzwer
2015年10月04日NOIP模拟赛 by hzwer (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...
- 大家AK杯 灰天飞雁NOIP模拟赛题解/数据/标程
数据 http://files.cnblogs.com/htfy/data.zip 简要题解 桌球碰撞 纯模拟,注意一开始就在袋口和v=0的情况.v和坐标可以是小数.为保险起见最好用extended/ ...
- 队爷的讲学计划 CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的讲学计划 题解:刚开始理解题意理解了好半天,然后发 ...
- 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的Au%20Plan 题解:看了题之后觉得肯定是DP ...
- 队爷的新书 CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的新书 题解:看到这题就想到了 poetize 的封 ...
- CH Round #58 - OrzCC杯noip模拟赛day2
A:颜色问题 题目:http://ch.ezoj.tk/contest/CH%20Round%20%2358%20-%20OrzCC杯noip模拟赛day2/颜色问题 题解:算一下每个仆人到它的目的地 ...
- CH Round #52 - Thinking Bear #1 (NOIP模拟赛)
A.拆地毯 题目:http://www.contesthunter.org/contest/CH%20Round%20%2352%20-%20Thinking%20Bear%20%231%20(NOI ...
- CH Round #49 - Streaming #4 (NOIP模拟赛Day2)
A.二叉树的的根 题目:http://www.contesthunter.org/contest/CH%20Round%20%2349%20-%20Streaming%20%234%20(NOIP 模 ...
随机推荐
- Scrum立会报告+燃尽图(十月十三日总第四次):前期宣传相关工作
此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2194 Scrum立会master:刘欣 一.小组介绍 组长:付佳 组员: ...
- 20181120-8 Beta阶段第2周/共2周 Scrum立会报告+燃尽图 05
此作业要求参见[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2413] 版本控制地址 [https://git.coding.ne ...
- 1.12Linux下软件安装(学习过程)
实验介绍 介绍 Ubuntu 下软件安装的几种方式,及 apt,dpkg 工具的使用. 一.Linux 上的软件安装 通常 Linux 上的软件安装主要有三种方式: 在线安装 从磁盘安装deb软件包 ...
- python 动态获取当前运行的类名和函数名的方法
一.使用内置方法和修饰器方法获取类名.函数名 python中获取函数名的情况分为内部.外部,从外部的情况好获取,使用指向函数的对象,然后用__name__属性 复制代码代码如下: def a():pa ...
- J2EE Oa项目上传服务器出现的乱码解决过程
(= =)搞了许久觉得有必要记下来.. 由于我本地的mysql都设置好了,但是服务器的又不能去改它 毕竟还有其他人要用- -: 所以只能是我建的时候去设置一下了, 首先先建数据库 ,表;; creat ...
- 60行代码:Javascript 写的俄罗斯方块游戏
哈哈这个实在是有点意思 备受打击当初用java各种类写的都要几百行啦 先看效果图: 游戏结束图: javascript实现源码: [javascript] view plaincopyprint? & ...
- 自定义ClassLoader,用于加载用户JAR包
最近在考虑C/S结构程序的软件自动升级的实现方式,比如QQ.飞信等都自动升级的功能. 自动升级模块虽然还没有编码完成,但是思路还是比较清晰的. 自动升级过程中,升级文件的JAR包是专门加载到程序中去的 ...
- 0302借软件工程触IT
没有不想学好的学生,也没有选择计算机软件专业后不想过能进军IT的行业的.就对于自己情况来说,大学选择计算机商业软件专业学习也有一年多时间了,未接触专业知识前IT是一个高大上的向往,在初学C语 ...
- 敏捷冲刺DAY4
一. 每日会议 1. 照片 2. 昨日完成工作 登录界面的进一步完善 服务器搭建 建立数据库 3. 今日完成工作 发布和提供需求功能的实现 用户修改自己的信息 用户界面设计 管理员界面设计 4. 工作 ...
- QSettings配置读写-win注册表操作-ini文件读写
版权声明:若无来源注明,Techie亮博客文章均为原创. 转载请以链接形式标明本文标题和地址: 本文标题:QSettings配置读写-win注册表操作-ini文件读写 本文地址:http:// ...