SZU 7
A - Megacity
sqrtf是个坑
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue int n,s; struct point
{
int x,y,h;
double d;
}p[]; int cmp(const point& a,const point& b)
{ return a.d<=b.d;} int main()
{
int i,j;
while(sf("%d%d",&n,&s)==)
{
if(s == )
{
pf("%.7f\n",);
continue;
}
mem(p,); for(i=;i<n;i++)
{
sf("%d%d%d",&p[i].x,&p[i].y,&p[i].h);
p[i].d = sqrtf(p[i].x*p[i].x + p[i].y*p[i].y);
}
sort(p,p+n,cmp); int sum = s;
double res = ;
int ok = ; for(i=;i<n;i++)
{
sum+=p[i].h;
if(sum>=)
{
ok = ;
res = p[i].d;
break;
}
}
if(ok)
{
pf("%.7f\n",res);
}
else
pf("-1\n");
}
}
B - Let's Watch Football
一看就知道可以计算,不要想太复杂
int main()
{
int i,j;
int a,b,c;
while(sf("%d%d%d",&a,&b,&c)==)
{
pf("%d\n",(a*c-b*c+b-)/b);
}
}
C - Hopscotch
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define mp make_pair
#define debug printf("!\n")
#define INF 1<<30
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue int main()
{
int T,r,i,j,n;
int a,x,y;
while(sf("%d%d%d",&a,&x,&y)==)
{
if(y%a==)
pf("-1\n");
else if(y<a)
{
if(*x<a && *x>-a)
pf("1\n");
else
pf("-1\n");
}
else
{
if((y-a)/a%==)
{
if(*x<a && *x>-a)
pf("%d\n",(y-a)/a/*+);
else
pf("-1\n");
}
else
{
if(x> && x<a)
pf("%d\n",((y-a)/a+)/*+);
else if(x< && x>-a)
pf("%d\n",((y-a)/a+)/*);
else
pf("-1\n");
}
}
}
}
Working out
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue int n,m; int a[][]; int dp[][][]; int main()
{
int i,j;
while(sf("%d%d",&n,&m)==)
{
for(i=;i<=n;i++)
{
for(j=;j<=m;j++)
{
sf("%d",&a[i][j]);
}
} for(i=;i<=n;i++)
{
for(j=;j<=m;j++)
{
dp[i][j][] = max(dp[i-][j][],dp[i][j-][])+a[i][j];
}
} for(i=n;i>=;i--)
{
for(j=m;j>=;j--)
{
dp[i][j][] = max(dp[i+][j][],dp[i][j+][])+a[i][j];
}
} for(i=;i<=n;i++)
{
for(j=m;j>=;j--)
{
dp[i][j][] = max(dp[i-][j][],dp[i][j+][])+a[i][j];
}
} for(i=n;i>=;i--)
{
for(j=;j<=m;j++)
{
dp[i][j][] = max(dp[i+][j][],dp[i][j-][])+a[i][j];
}
} int ans = ; for(i=;i<n;i++)
{
for(j=;j<m;j++)
{
ans = max(ans,dp[i][j-][]+dp[i][j+][]+dp[i-][j][]+dp[i+][j][]);
ans = max(ans,dp[i-][j][]+dp[i+][j][]+dp[i][j-][]+dp[i][j+][]);
}
} pf("%d\n",ans);
}
}
E - Anagram Search
打表法,因为?可以任意变,而且不在表范围内,所以只需要判断表范围内每个字母出现的数量
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define mp make_pair
#define debug printf("!\n")
#define INF 1<<30
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue char a[],b[]; int s[],t[]; int main()
{
int T,r,i,j,n;
while(sf("%s%s",a,b)==)
{
int al = strlen(a);
int bl = strlen(b); mem(s,);
mem(t,); for(i=;i<bl;i++)
{
if(b[i]!='?')
s[b[i]-'a']++;
} int cnt = ; for(i=;i<al;i++)
{
if(a[i]!='?') t[a[i]-'a']++;
int ok = ; if(i>=bl-)
{
for(j=;j<;j++)
{
if(t[j]>s[j])
{
ok = ;
break;
}
}
if(ok) cnt++;
t[a[i-bl+]-'a']--;
}
}
pf("%d\n",cnt);
}
}
SZU 7的更多相关文章
- P3436 [POI2006]PRO-Professor Szu
P3436 [POI2006]PRO-Professor Szu 题目描述 n个别墅以及一个主建筑楼,从每个别墅都有很多种不同方式走到主建筑楼,其中不同的定义是(每条边可以走多次,如果走边的顺序有一条 ...
- SZU:B47 Big Integer II
Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Normal Descrip ...
- SZU:D89 The Settlers of Catan
Judge Info Memory Limit: 65536KB Case Time Limit: 3000MS Time Limit: 3000MS Judger: Number Only Judg ...
- SZU:B47 Big Integer I
Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Normal Descrip ...
- SZU:G32 Mass fraction
Judge Info Memory Limit: 32768KB Case Time Limit: 5000MS Time Limit: 5000MS Judger: Float Numbers (1 ...
- SZU:J38 Number Base Conversion
Judge Info Memory Limit: 32768KB Case Time Limit: 1000MS Time Limit: 1000MS Judger: Number Only Judg ...
- SZU:B54 Dual Palindromes
Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Number Only Ju ...
- SZU:A66 Plastic Digits
Description There is a company that makes plastic digits which are primarily put on the front door o ...
- SZU:G34 Love code
Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Normal Descrip ...
- SZU:A25 Favorite Number
Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Number Only Ju ...
随机推荐
- P4597 序列sequence
传送门 题解 完全看不懂大佬们在说什么……特别是chen_zhe大佬写的…… 来说说个人的理解吧 大佬们说:考虑当前的数$x$和之前的最大数$y$,(默认$x<y$,因为如果$x>=y$已 ...
- [Swift]字符串(String类、NSString类)常用操作
NS是Cocoa类对象类型的前缀,来源于乔布斯建立的另一家公司--NeXTNSString的使用方法,和Swift语言中的String有很多相似之处. 1.字符串的定义String类 var str1 ...
- jmeter压力测试值之配置JDBC Connection Configuration(一)
一.下载mysql jar包 下载mysql jar包 http://dev.mysql.com/downloads/connector/j/ 网盘下载地址:mysql-connector-java- ...
- loj #6032. 「雅礼集训 2017 Day2」水箱 线段树优化DP转移
$ \color{#0066ff}{ 题目描述 }$ 给出一个长度为 \(n\) 宽度为 \(1\) ,高度无限的水箱,有 \(n-1\) 个挡板将其分为 \(n\) 个 \(1 - 1\) 的小格, ...
- Springboot第一篇:框架了解与搭建
在上一章,我讲解了React+node+express相应的框架搭建,一个项目只有一个前端框架够么,当然不够啦!!! 所以这节我们就来讲后台springboot框架的搭建和相关原理吧~~~版本(2.1 ...
- Entity Framework添加记录时获取自增ID值
与Entity Framework相伴的日子痛并快乐着.今天和大家分享一下一个快乐,两个痛苦. 先说快乐的吧.Entity Framework在将数据插入数据库时,如果主键字段是自增标识列,会将该自增 ...
- 【Python】批量检测百度权重
挖洞过程中收集了站点后,我一般习惯查看站点的百度权重值,为了方便,写了一个简单的脚本, 至于结果如何显示,看个人需求吧,我这里只是简单的列一下,脚本如下: #coding:utf-8 import r ...
- node.js修改全局安装文件路径
在进行 node.js 的开发过程中,我们需要下载大量的依赖模块,为了不让 c 盘的东西太过于散乱,可以通过修改node的配置参数,来修改node依赖的下载路径. 步骤: ①创建两个文件夹:node_ ...
- tomcat各文件夹及作用
1.bin目录:这个文件夹包含的是启动/关闭tomcat的脚本 2.conf目录:主要是用来存放一些Tomcat的配置文件,都是一些.xml部署文件,其中重要的有: server.xml:是Tomca ...
- sizeof(数组名) 与 数组长度
int a[] = {1, 2, 3, 4}; cout << sizeof(a); //16 char b[] = "abc"; cout << size ...