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. scrum立会报告+燃尽图(第三周第七次)

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2286 项目地址:https://coding.net/u/wuyy694 ...

  2. 第六次作业psp

    psp 进度条 代码累积折线图 博文累积折线图 psp饼状图

  3. 探路者 Alpha阶段中间产物

     版本控制 git地址:https://git.coding.net/clairewyd/toReadSnake.git   贪吃蛇(单词版)软件功能说明书 1 开发背景 “贪吃蛇”这个游戏对于80, ...

  4. 第二次c++作业(觉得渐渐入门系列)

    其实说实话,我还是不敢很确定地说面向对象和面向过程这两种语言,我确实能分得开,但是我觉得倒是比以前好很多了.//(大概是谈了对象,知道了什么是面向对象编程) 1.从个人角度来说, a:面向过程就是-- ...

  5. hdu1242 Rescue DFS(路径探索题)

    这里我定义的路径探索题指 找某路能够到达目的地,每次走都有方向,由于是探索性的走 之后要后退 那些走过的状态都还原掉 地址:http://acm.hdu.edu.cn/showproblem.php? ...

  6. 如何改变placeholder的颜色

    :-moz-placeholder { /* Mozilla Firefox 4 to 18 */ color: #f00; } ::-moz-placeholder { /* Mozilla Fir ...

  7. CodeForces Round #527 (Div3) C. Prefixes and Suffixes

    http://codeforces.com/contest/1092/problem/C Ivan wants to play a game with you. He picked some stri ...

  8. 关于解决java读取excel文件遇空行抛空指针的问题 !

    关于解决java读取excel文件遇空行抛空指针的问题 ! package exceRead; import java.io.File; import java.io.FileInputStream; ...

  9. PHP面向对象之抽象类,抽象方法

    抽象类,抽象方法 抽象类: 是一个不能实例化的类: 定义形式: abstract  class  类名{} 为什么需要抽象类: 它是为了技术管理而设计! 抽象方法: 是一个只有方法头,没有方法体的方法 ...

  10. 第117天:Ajax实现省市区三级联动

    Ajax实现省市区三级联动 思路: (1)首先获取省份信息 (2)发起Ajax请求,注意dataType中的T大写 (3)封装回调函数,回调函数success中用$.each循环每一条数据,动态创建o ...