A FZU-2054

水题,比较A,B双方的最大值即可。

B FZU-2055

string,截取‘.’之前和之后然后和给出的文件夹名和拓展名比较就好了啊,不明白为什么那么多人错。

代码:

 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = ;
string path[maxn], type[maxn];
int main()
{
int T; scanf("%d", &T);
while(T--)
{
int n, m; scanf("%d%d", &n, &m);
string str;
for(int i = ; i < n; i++)
{
cin >> str;
int pos = str.find_last_of('.');
path[i] = str.substr(, pos);
type[i] = str.substr(pos);
}
string t1, t2;
for(int i = ; i < m; i++)
{
cin >> t1 >> t2;
for(int j = ; j < n; j++)
{
if(t2 != type[j]) continue;
if(t1.length() > path[j].length()) continue;
string tmp = path[j].substr(, t1.length());
if(tmp == t1) {cout << path[j] << type[j] << endl;}
}
} }
return ;
}

C FZU-2056

题意:现在有一个n*m的矩阵A,在A中找一个H*H的正方形,使得其面积最大且该正方形元素的和不大于 limit。

分析:开始以为是DP或者二维RMQ,其实用二分就可以做出来;

   在输入时构造元素和矩阵dp[][](即dp[i][j]为从(1,1)到(i,j)的矩形范围元素和);再在(0,min(m,n))范围内二分查找满足条件的最优解H;

   计算正方形内元素和的方法要掌握;

代码:

 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
const int maxn = ;
int m, n, lim;
int dp[maxn][maxn];
bool solve(int h)
{
// if(h == 1) return
for(int i = h; i <= n; i++)
{
for(int j = h; j <= m; j++)
{
if(dp[i][j]-dp[i-h][j]-dp[i][j-h]+dp[i-h][j-h] > lim) continue;
return true;
}
}
return false;
}
int main()
{
int T; scanf("%d", &T);
while(T--)
{
scanf("%d%d%d", &n, &m, &lim);
memset(dp, , sizeof(dp));
for(int i = ; i <= n; i++)
{
int tmp = ;
for(int j = ; j <= m; j++)
{
int x; scanf("%d", &x);
tmp += x;
dp[i][j] = dp[i-][j]+tmp;
}
} int H = min(n, m);
int L = , R = H;
int M;
while(L < R)
{
M = L+(R-L)/;
if(M == L) M++;
if(solve(M)) L = M;
else R = M-;
}
cout << L*L << endl;
}
return ;
}

D FZU-2057

题意:给出一树状家谱图,再给出两个人,问两人什么关系;

分析:又想复杂了,只要在输入时记录下父子母子关系,性别,然后由长辈往下搜就行,如果是男的就输出'F',女的输出‘M’,搜不到时注意改变长幼关系再搜一次,如果还搜不到就输出Relative;

代码:

 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<stack>
using namespace std;
const int maxn = ;
int vis[maxn], child[maxn], sex[maxn];
stack<int> vv;
struct Node
{
int f, m, sex;
bool operator == (const Node& rhs) const
{
return f==rhs.f && m == rhs.m;
}
}nodes[maxn];
void print()
{
while(!vv.empty()){
int t = vv.top(); vv.pop();
if(t == ) printf("F");
else if(t == )printf("M");
}
printf("\n");
}
bool dfs(int u, int v)
{
while(!vv.empty()) vv.pop();
while(u != v)
{
if(sex[u] == )
vv.push();
else if(sex[u] == )
vv.push();
else
break;
u = child[u];
}
if(u == v)
return true;
else return false;
} int main()
{
int T; scanf("%d", &T);
while(T--)
{
memset(sex, , sizeof(sex));
int n; scanf("%d", &n);
int a, b, c;
for(int i = ; i<n/; i++)
{
scanf("%d%d%d", &a, &b, &c);
// nodes[a].f = b, nodes[a].m = c;
sex[b] = , sex[c] = ;
child[b] = child[c] = a;
}
int m; scanf("%d", &m);
while(m--)
{
int x, y; scanf("%d%d", &x, &y);
if(dfs(x, y))
{
printf("0 ");
print();
}
else if(dfs(y, x))
{
printf("1 ");
print();
}
else
printf("Relative\n");
}
}
return ;
}

E FZU-2058

题意:给出N个元素,问有多少对元素的和是M;

分析:一种常见的简单思路题;二层循环不用想肯定超时,dp当然也用不上,对于其中一个元素x,排序后用二分或者lower_bound/upper_bound函数搜索M-x的个数就好啦。

代码:

 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = ;
LL a[maxn];
LL n, m; LL solve()
{
LL cnt = ;
for(int i = ; i < n; i++)
{
LL t = m-a[i];
int pos1 = upper_bound(a+i+, a+n, t)-a-i-;
int pos2 = lower_bound(a+i+, a+n, t)-a-i-;
cnt += pos1-pos2;
}
return cnt;
} int main()
{ while(~scanf("%I64d%I64d", &n, &m))
{
for(int i = ; i < n; i++)
{
scanf("%I64d", &a[i]);
}
sort(a, a+n);
printf("%I64d\n", solve());
} return ;
}

F FZU-2059

G FZU-2060

心好累,我再想想T ^ T;

I FZU-2062

题意:要想得到1~n之间的所有数,最少需要多少个数。

分析:确实是个有点意思的水题,前提是要想到十进制可以用二进制转换啊!愚蠢!不行得多练练位运算...

以n=5为例:

  5 = 1+2+2;

  4 = 2+2;

  3 = 1+2;

  2 = 2;

  1 = 1;

答案:log2(n)

J FZU-1859

题意:画图题,HDU2083的简化,递归画图就行;当然也有找规律画出来的,且待我研究研究...

 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = ; int pic[maxn][maxn]; void print(int x, int y, int n)
{
if(n == ) {pic[x][y] = ''; return;}
print(x, y, n-);
print(x+(<<(n-)), y, n-);
print(x+(<<(n-)), y+(<<(n-)), n-);
} int main()
{
int T; scanf("%d", &T);
while(T--)
{
memset(pic, , sizeof(pic));
int n; scanf("%d", &n);
print(, , n);
for(int i = ; i <= (<<(n-)); i++)
{
for(int j = ; j <= i; j++)
if(pic[i][j]) printf("@"); else printf(" ");
printf("\n");
}
} return ;
}

K FZU-1862

题意:给出一个环,按顺时针的顺序求出下标为L,R之间的最大的数;

分析:这题感觉时间上自己是水过去的,把环变成数组先打表求出各区间的最大值,然后输出即可。灰常简单的转化技巧。

 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = ;
int m[maxn], Max[maxn][maxn];
int main()
{
int n;
int kase = ;
while(~scanf("%d", &n))
{
printf("Case #%d:\n", ++kase);
for(int i = ; i <= n; i++) scanf("%d", &m[i]);
for(int i = ; i <= n; i++) m[n+i] = m[i];
memset(Max, -, sizeof(Max));
for(int i = ; i <= n; i++)
{
for(int j = i; j <= n+i; j++)
{
Max[i][j] = max(Max[i][j-], m[j]);
}
}
int q; scanf("%d", &q);
for(int i = ; i < q; i++)
{
int a, b; scanf("%d%d", &a, &b);
if(a <= b) printf("%d\n", Max[a][b]);
else printf("%d\n", Max[a][b+n]);
}
printf("\n");
}
return ;
}

【补】【FZU月赛】【20150515】【待续】的更多相关文章

  1. fzu月赛 2203 单纵大法好 二分

    Accept: 8    Submit: 18Time Limit: 5000 mSec    Memory Limit : 65536 KB  Problem Description 人在做,天在看 ...

  2. FZU月赛20160416 ABEF

    Problem A ABCDEFG Accept: 302    Submit: 442Time Limit: 1000 mSec    Memory Limit : 32768 KB  Proble ...

  3. Fzu月赛11 老S的旅行计划 dij

    Description 老S在某城市生活的非常不自在,想趁着ICPC举办期间在省内转转.已知老S所在的省有N个城市,M条无向边(对于某一对结点可能出现重边).由于省内的交通相当糟糕,通过某条边所需要花 ...

  4. fzu月赛(2015.11)(思维)

    Problem 2205 据说题目很水 Sunday最近对图论特别感兴趣,什么欧拉回路什么哈密顿回路,又是环又是树.在看完一本书后,他对自己特别有信心,便找到大牛牛犇犇,希望他出一题来考考自己. 在遥 ...

  5. 【FZU】2152 文件系统

     Problem 2152 文件系统 Accept: 63    Submit: 126 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Probl ...

  6. 【LGR-049】洛谷7月月赛

    Preface Luogu八月月赛都结束了我才来补七月月赛 这次月赛还是很狗的,在绍一的晚上恰逢刮台风,然后直接打到一半断网了 结果都没有交上去GG 感觉这次难度适中,解法也比较清新自然吧,十分给个九 ...

  7. luogu11月月赛T3咕咕咕(组合数学)

    题目描述 小 F 是一个能鸽善鹉的同学,他经常把事情拖到最后一天才去做,导致他的某些日子总是非常匆忙. 比如,时间回溯到了 2018 年 11 月 3 日.小 F 望着自己的任务清单: 看 iG 夺冠 ...

  8. 「P4996」「洛谷11月月赛」 咕咕咕(数论

    题目描述 小 F 是一个能鸽善鹉的同学,他经常把事情拖到最后一天才去做,导致他的某些日子总是非常匆忙. 比如,时间回溯到了 2018 年 11 月 3 日.小 F 望着自己的任务清单: 看 iG 夺冠 ...

  9. FZU Problem 2156 Climb Stairs DP

    http://acm.fzu.edu.cn/problem.php?pid=2156 题目大意: 爬楼梯,要爬到n这个位置,每次可以走x也可以走y,然后一定要经过A和B两点,求最终到达n的方案数. 思 ...

随机推荐

  1. js特效-仿照html属性title写一个弹出标题样式

    问题场景:商品描述,当营业员给客户介绍时会看着这些弹出标题来给客户讲解描述,一般采用html中属性title来实现,但是有些商品描述太长,这些title在IE浏览器中大约展示5s,营业员需要多次移动鼠 ...

  2. 自定义使用AVCaptureSession 拍照,摄像,载图

    转载自 http://blog.csdn.net/andy_jiangbin/article/details/19823333 拍照,摄像,载图总结 1 建立Session  2 添加 input  ...

  3. Scala List的排序函数sortWith

    //原始方法: //val list=List("abc","bcd","cde") scala> list.sortWith( (s ...

  4. PostgreSQL的 initdb 源代码分析之十二

    继续分析 /* Now create all the text config files */ setup_config(); 将其展开: 实质就是,确定各种参数,分别写入 postgresql.co ...

  5. 文件映射spring 使用classpath方式加载hibernate映射文件

    在改章节中,我们主要介绍文件映射的内容,自我感觉有个不错的建议和大家分享下 <!-- 批量指定到classpath下面 --> <property name="mappin ...

  6. 使用CKEditor编辑器进行文本编辑

    首先下载CKEditor. 下载地址:点击打开链接 将下载完的CKEditor解压而且导入到项目中. 然后在页面引入CKEditor <script type="text/javasc ...

  7. WPF UI布局之概述

    在线演示:http://v.youku.com/v_show/id_XNzA5NDk2Mjcy.html 清晰版视频+代码下载:http://115.com/lb/5lbeer0m9lad 一.简单介 ...

  8. 第十七章,txt文件的写入和读取数据结合练习(C++)

    #include <iostream> #include <fstream> int main(int argc, char** argv) { std::string str ...

  9. 测试JS

    <html> <head> </head> <body> <script> function loadScript(url, callbac ...

  10. NSRange类详解

    NSRange的定义 { NSUInteger location; NSUInteger length; } NSRange; NSRange是一个结构体,其中location是一个以0为开始的ind ...