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. 互评Alpha版本——杨老师粉丝群——Pinball

    一.基于NABCD评论作品,及改进建议 1.根据(不限于)NABCD评论作品的选题 (1)N(Need,需求) 成语学习对除汉语言专业外的大学生的需求并不是很高,初中生和高中生因为在升学时需要参加语文 ...

  2. 《Linux内核与分析》第六周

    20135130王川东 1.操作系统的三大管理功能包括:进程管理,内存管理,文件系统. 2. Linux内核通过唯一的进程标识PID来区别每个进程.为了管理进程,内核必须对每个进程进行清晰的描述,进程 ...

  3. c# 简单日志记录

    FileStream fs = new FileStream(System.AppDomain.CurrentDomain.BaseDirectory + "log.txt",Fi ...

  4. SGU 181 X-Sequence(一题比较水的求模找规律)

    E - X-Sequence Time Limit:500MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Submit ...

  5. Nodejs学习笔记(一)--- 操作Mysql数据库

    对于一门语言的学习,我个人觉得最好的方式就是通过一个项目来展示,所以从基本的一些模块去了解是最好的方式对于Mysql怎么去链接数据库这个我是在网上找到的(其实一直想找官方文档的,发现没有它的踪迹,(后 ...

  6. Lucene 分词

    在Lucene中很多数据是通过Attribute进行存储的 步骤是同过TokenStrem获取文本信息流 TokenStream stream = a.tokenStream("conten ...

  7. HDU 2162 Add ‘em

    http://acm.hdu.edu.cn/showproblem.php?pid=2162 Problem Description Write a program to determine the ...

  8. mysql中约束

    约束 什么叫做约束? 约束,就是要求数据需要满足什么条件的一种“规定”. 主要有如下几种约束: 主键约束:形式: primary key ( 字段名); 含义(作用):使该设定字段的值可以用于“唯一确 ...

  9. Debugger DataSet 调试时查看DataSet

    delphi  跟踪调试的时候查看DataSet数据记录 Ctrl+F7调试 增强工具DataSethttp://edn.embarcadero.com/article/40268 http://do ...

  10. 第192天:js---Date对象属性和方法总结

    Date对象构造函数重载方法 一.第一种重载方法---基本 当前时间 //构造函数 - 第一种重载方法:基本 当前时间 console.log('构造函数 - 第一种重载方法:基本 当前时间') da ...