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

  1. P3436 [POI2006]PRO-Professor Szu

    P3436 [POI2006]PRO-Professor Szu 题目描述 n个别墅以及一个主建筑楼,从每个别墅都有很多种不同方式走到主建筑楼,其中不同的定义是(每条边可以走多次,如果走边的顺序有一条 ...

  2. SZU:B47 Big Integer II

    Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Normal Descrip ...

  3. SZU:D89 The Settlers of Catan

    Judge Info Memory Limit: 65536KB Case Time Limit: 3000MS Time Limit: 3000MS Judger: Number Only Judg ...

  4. SZU:B47 Big Integer I

    Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Normal Descrip ...

  5. SZU:G32 Mass fraction

    Judge Info Memory Limit: 32768KB Case Time Limit: 5000MS Time Limit: 5000MS Judger: Float Numbers (1 ...

  6. SZU:J38 Number Base Conversion

    Judge Info Memory Limit: 32768KB Case Time Limit: 1000MS Time Limit: 1000MS Judger: Number Only Judg ...

  7. SZU:B54 Dual Palindromes

    Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Number Only Ju ...

  8. SZU:A66 Plastic Digits

    Description There is a company that makes plastic digits which are primarily put on the front door o ...

  9. SZU:G34 Love code

    Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Normal Descrip ...

  10. SZU:A25 Favorite Number

    Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Number Only Ju ...

随机推荐

  1. [Objective-C语言教程]常量(7)

    常量指的是程序在执行期间不会改变的固定值.这些固定值也称为文字.常量可以是任何基本数据类型,如整数常量,浮点常量,字符常量或字符串文字.还有枚举常量.常量被视为常规变量,只不过它们的值在定义后无法修改 ...

  2. Laravel 集成 JPush 极光推送指北

    我是一个 Laravel 小白,我是一个 Laravel 小白,我是一个 Laravel 小白(默念三遍再往下读,如果非小白就不用看了). Laravel 使用 Composer 来管理代码依赖.所以 ...

  3. 关于word转化成xml,图片的转换

    当word另存为xml的时候,其中的图片会以Base64编码形式展示在xml文件的特定位置, java中操作图片转换成64位编码的方式: 可将返回的64直接放在前面的未知即可:

  4. NSUserdefault读书笔记

    作用 用来存储首选项的.本来首选项是存在磁盘上的,NSUserdefault相当于提供了一个缓存,不用每次都写文件.也就是说设置首选项以后,可以马上读出来,不必先写到磁盘中去. 定期调用synchro ...

  5. 各种 Python 库/模块/工具

    1 算法 1.1 字符串处理 re 正则表达式的标准库. StringIO / cStringIO 以读写文件的方式来操作字符串(有点类似于内存文件). cStringIO 是 C 语言实现的,提供高 ...

  6. python爬虫学习心得

    作为一名python的忠实爱好者,我开始接触爬虫是在2017年4月份,最开始接触它的时候遇到两个梗,一个是对python还不算太了解(当然现在也仍然在努力学习它的有关内容),二是对爬虫心怀一份敬畏之心 ...

  7. 2019.2.14 t3 车辆销售

    用算法求最大生成树,在并查集合并时,把原本的一个根连向另一个 根改成两个根都连向一个新建的节点,并把当前正在处理的边的权值赋给这个新 节点做点权.这样形成的结构会是一棵树. 一个点的答案大致上是树的根 ...

  8. ubuntu->错误

    1.dpkg *** locked 原因:安装某个包不成功, 可以使用命令 dpkg --configure -a 来重启中断的安装过程 如果屡次安装不成功放弃安装,则删除 lock 2.flashp ...

  9. HTTP请求处理流程-SpringMvc

    1.在SpringMVC的http请求处理过程中,包括了前端控制器(DispatcherServlet).处理映射器(HandlerMapping).处理适配器(HandlerAdapter).处理器 ...

  10. Rstudio常用且不熟快捷键 “原版+中文” 整理