[topcoder]SRM 633 DIV 2
第一题,http://community.topcoder.com/stat?c=problem_statement&pm=13462&rd=16076
模拟就可以了。
#include <vector>
#include <algorithm> using namespace std; class Target {
public:
vector <string> draw(int n) {
vector<string> result(n, string(n, ' '));
int x = 0;
int y = 0;
while (n >= 1) {
for (int i = 0; i < n; i++) {
result[x + i][y] = '#';
result[x][y + i] = '#';
result[x + n - 1][y + i] = '#';
result[x + i][y + n - 1] = '#';
}
x += 2;
y += 2;
n -= 4;
}
return result;
}
};
第二题,想了很久。最后发现用三角形的A+B>=C,一个一个推,可以推出N条边所组成的多边形(开口)的距离范围。http://apps.topcoder.com/wiki/display/tc/SRM+633#Jumping
有详细的图示。
#include <vector>
#include <algorithm>
#include <string>
#include <algorithm>
using namespace std; class Jumping {
public:
string ableToGet(int x, int y, vector <int> jumpLengths) {
double d = sqrt(1.0 * x * x + 1.0 * y * y);
sort(jumpLengths.begin(), jumpLengths.end());
double low = jumpLengths[0];
double high = jumpLengths[0];
for (int i = 1; i < jumpLengths.size(); i++) {
low = max(0.0, jumpLengths[i] - high);
high = high + jumpLengths[i];
}
if (d >= low && d <= high) {
return "Able";
} else {
return "not able";
} } };
第三题,没做。后来看题解,就是用LCD和GCD的限制,得到x*y,然后穷举搜索。用DFS。
[topcoder]SRM 633 DIV 2的更多相关文章
- TopCoder SRM 633 Div.2 500 Jumping
题意:给一个点(x,y),给一些步长delta1,delta2...deltaN,问从(0,0)严格按照步长走完N步后能否正好到达(x,y)点. 解法:其实就是判断这些线段和(0,0)-(x,y)这条 ...
- TopCoder SRM 560 Div 1 - Problem 1000 BoundedOptimization & Codeforces 839 E
传送门:https://284914869.github.io/AEoj/560.html 题目简述: 定义"项"为两个不同变量相乘. 求一个由多个不同"项"相 ...
- TopCoder SRM 667 Div.2题解
概览: T1 枚举 T2 状压DP T3 DP TopCoder SRM 667 Div.2 T1 解题思路 由于数据范围很小,所以直接枚举所有点,判断是否可行.时间复杂度O(δX × δY),空间复 ...
- [topcoder]SRM 646 DIV 2
第一题:K等于1或者2,非常简单.略.K更多的情况,http://www.cnblogs.com/lautsie/p/4242975.html,值得思考. 第二题:http://www.cnblogs ...
- TopCoder SRM 596 DIV 1 250
body { font-family: Monospaced; font-size: 12pt } pre { font-family: Monospaced; font-size: 12pt } P ...
- Topcoder SRM 656 (Div.1) 250 RandomPancakeStack - 概率+记忆化搜索
最近连续三次TC爆零了,,,我的心好痛. 不知怎么想的,这题把题意理解成,第一次选择j,第二次选择i后,只能从1~i-1.i+1~j找,其实还可以从j+1~n中找,只要没有被选中过就行... [题意] ...
- Topcoder SRM 648 (div.2)
第一次做TC全部通过,截图纪念一下. 终于蓝了一次,也是TC上第一次变成蓝名,下次就要做Div.1了,希望div1不要挂零..._(:зゝ∠)_ A. KitayutaMart2 万年不变的水题. # ...
- 【topcoder SRM 702 DIV 2 250】TestTaking
Problem Statement Recently, Alice had to take a test. The test consisted of a sequence of true/false ...
- TopCoder SRM 639 Div.2 500 AliceGameEasy
题意: 一个游戏有n轮,有A和B比赛,谁在第 i 轮得胜,就获得 i 分,给出x,y,问A得x分,B得y分有没有可能,如果有,输出A最少赢的盘数 解题思路: 首先判断n(n+1)/2 = (x+y)是 ...
随机推荐
- Ueeidor 使用
setContent 要放在 ue.read(function(){ })中... js 字符串参数不要忘记 引号.....而且最好是单引号!!!
- 最长子序列问题(二分+贪心nlogn算法)
[题目描述] 给定N个数,求这N个数的最长上升子序列的长度. [样例输入] 7 2 5 3 4 1 7 6 [样例输出] 4 什么是最长上升子序列? 就是给你一个序列,请你在其中求出一段不断严格上升的 ...
- Linux 防火墙iptables 实例
iptables的基本语法格式 iptables [-t 表名] 命令选项 [链名] [条件匹配] [-j 目标动作或跳转] 说明:表名.链名用于指定iptables命令所操作的表和链,命令选项用于指 ...
- 9 Strings
1 Strings 1.1 Strings and GStrings Groovy允许你使用2种不同类型的字符串类型,分别是java.lang.String和groovy.lang.GS ...
- thinkPHP Model的操作
1.建立一个表 create table Demo( -> id int, ), -> age int, ) -> ); 2.新增数据 2.1面向过程的风格 $d = $a-> ...
- 25-----BBS论坛
BBS论坛(二十五) 25.1.发布帖子后台逻辑完成 (1)apps/models.py class PostModel(db.Model): __tablename__ = 'post' id = ...
- Mybatis学习笔记6 - #{}和${}
#{}:可以获取map中的值或者pojo对象属性的值.${}:可以获取map中的值或者pojo对象属性的值. 区别: #{}:是以预编译的形式,将参数设置到sql语句中:PreparedStateme ...
- OpenStack Weekly Rank 2015.08.24
Module Reviews Drafted Blueprints Completed Blueprints Filed Bugs Resolved Bugs Cinder 5 1 1 6 13 Sw ...
- Spark集群安装MySQL环境
1.修改yum源 鉴于用国外的Yum源,速度比较慢,所以想到将国外的yum源改为国内的Yum源,这里选择使用比较多的阿里云源.具体修改方法可以参考此连接 我们先新建一个新的文件用来存放Yum源: [k ...
- pat1043. Is It a Binary Search Tree (25)
1043. Is It a Binary Search Tree (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...