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的更多相关文章

  1. NOIP模拟赛20161022

    NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...

  2. contesthunter暑假NOIP模拟赛第一场题解

    contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...

  3. NOIP模拟赛 by hzwer

    2015年10月04日NOIP模拟赛 by hzwer    (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...

  4. 大家AK杯 灰天飞雁NOIP模拟赛题解/数据/标程

    数据 http://files.cnblogs.com/htfy/data.zip 简要题解 桌球碰撞 纯模拟,注意一开始就在袋口和v=0的情况.v和坐标可以是小数.为保险起见最好用extended/ ...

  5. 队爷的讲学计划 CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的讲学计划 题解:刚开始理解题意理解了好半天,然后发 ...

  6. 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的Au%20Plan 题解:看了题之后觉得肯定是DP ...

  7. 队爷的新书 CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的新书 题解:看到这题就想到了 poetize 的封 ...

  8. CH Round #58 - OrzCC杯noip模拟赛day2

    A:颜色问题 题目:http://ch.ezoj.tk/contest/CH%20Round%20%2358%20-%20OrzCC杯noip模拟赛day2/颜色问题 题解:算一下每个仆人到它的目的地 ...

  9. CH Round #52 - Thinking Bear #1 (NOIP模拟赛)

    A.拆地毯 题目:http://www.contesthunter.org/contest/CH%20Round%20%2352%20-%20Thinking%20Bear%20%231%20(NOI ...

  10. CH Round #49 - Streaming #4 (NOIP模拟赛Day2)

    A.二叉树的的根 题目:http://www.contesthunter.org/contest/CH%20Round%20%2349%20-%20Streaming%20%234%20(NOIP 模 ...

随机推荐

  1. Beta冲刺第二周王者荣耀交流协会第四次会议

    1.例会照片: 成员:王超,高远博,冉华,王磊,王玉玲,任思佳,袁玥全部到齐. master:王玉玲 2.时间跨度: 2017年11月20日 18:00 — 18:13,总计13分钟. 3.地点: 一 ...

  2. c# 读取blob数据

    Stream stream = new MemoryStream(data); BinaryReader r = new BinaryReader(stream); int iRawImageWidt ...

  3. 软工实践第八次作业(课堂实战)- 项目UML设计(第五组)

    本次作业博客 团队信息 队名:起床一起肝活队 原组长: 白晨曦(101) 原组员: 李麒 (123) 陈德斌(104) 何裕捷(214) 黄培鑫(217) 王焕仁(233) 林志华(128) 乐忠豪( ...

  4. HDU 5167 Fibonacci 筛法+乱搞

    题目链接: hdu: http://acm.hdu.edu.cn/showproblem.php?pid=5167 题意: 给你一个x,判断x能不能由斐波那契数列中的数相乘得到(一个数可以重复使用) ...

  5. Alpha 冲刺9

    队名:日不落战队 安琪(队长) 今天完成的任务 协助开发手写涂鸦demo. okhttp学习第三弹. 明天的计划 协助开发语音存储demo. 还剩下的任务 个人信息数据get. 遇到的困难 困难:整理 ...

  6. Websphere Application Server 环境配置与应用部署最佳实践

    在发布一个运行于 WebSphere Application Server 的 J2EE 应用之前,对服务器进行配置和部署应用是必不可少的一个过程,这个过程是非常复杂的.WAS 为用户提供了可视化的管 ...

  7. PAT L1-017 到底有多二

    https://pintia.cn/problem-sets/994805046380707840/problems/994805121500692480 一个整数“犯二的程度”定义为该数字中包含2的 ...

  8. 【Apache】ab工具

    格式:ab  [options] [http://]hostname[:port]/path -n requests Number of requests to perform //在测试会话中所执行 ...

  9. MySQL存储引擎InnoDB与Myisam

    InnoDB与Myisam的六大区别 InnoDB与Myisam的六大区别 MyISAM InnoDB 构成上的区别: 每个MyISAM在磁盘上存储成三个文件.第一个 文件的名字以表的名字开始,扩展名 ...

  10. mysql(六)索引的数据结构

    先做抽象定义如下: 定义一条数据记录为一个二元组[key, data],key为记录的键值,对于不同的数据记录,key是互不相同的:data为数据记录除key外的数据. B-tree的特点: d为大于 ...