soj
文章平均质量分 58
mayer314
这个作者很懒,什么都没留下…
展开
-
Sicily 1491 Look and Say
// Problem#: 1491// Submission#: 3178088// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by原创 2014-11-08 20:40:27 · 393 阅读 · 0 评论 -
Sicily 2010 H Number
恩,直接从1开始查找就好// Problem#: 2010// Submission#: 3290303// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.o原创 2014-11-29 11:17:57 · 269 阅读 · 0 评论 -
Sicily 1014 畅通工程
Description某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。每组数据第一行包含原创 2014-11-06 19:11:54 · 911 阅读 · 0 评论 -
Sicily 4428 How Many Sets
动态规划,状态转移方程dp[i][j] = dp[i - 1][j] + dp[i - 2][j - 1]其中i表示总数,j表示取出的数个数。初始化时要注意顺序问题,设取出个数为k,则所有2k-1的项都应当为0,但特殊情况是取出一个时有几个数就输出几个。另外一个特殊情况就是0,直接输出空集1。// Problem#: 4428// Submission#: 3295621// The so原创 2014-11-30 15:35:11 · 613 阅读 · 0 评论 -
Sicily 1211 商人的宣传
动态规划,建一个vector vec[i]用来储存i为起点,接下来一天内能走到的其他点,接下来累加就可以// Problem#: 1211// Submission#: 3257911// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported原创 2014-11-29 08:07:26 · 393 阅读 · 0 评论 -
Sicily 1021 Couples
直接用栈模拟即可// Problem#: 1021// Submission#: 2839209// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/l原创 2014-11-30 09:43:20 · 319 阅读 · 0 评论 -
Sicily 1935 二叉树重建
题目要求说的很清楚,给出一个数的先序和中序遍历结果,构建树并按照广度优先输出。先序遍历的第一个数即为根节点,在中序遍历中找到之后它左面的都是左子孙结点右边同理。// Problem#: 1935// Submission#: 3291146// The source code is licensed under Creative Commons Attribution-NonCommerc原创 2014-11-29 19:36:28 · 389 阅读 · 0 评论 -
Sicily 2015 A New Year Gift
一开始的想法是排序后进行模拟,但是提交之后发现会超时。参考了各位大神的思路,采用原创 2014-11-24 21:37:39 · 312 阅读 · 0 评论 -
Sicily 1570 Hopeless Coach
给定接下来的轮次以及最低获得的积分,否则教练就会下课。刚开始推了很久的公式,觉得加起来项数好多,好烦。后来突然想到直接就是一个dp问题,按照上次的积分扫就可以,最后输出N轮时得分大于P分的总和概率即可// Problem#: 1570// Submission#: 3307174// The source code is licensed under Creative Commons At原创 2014-12-03 13:44:48 · 342 阅读 · 0 评论 -
Sicily 1543 Completing Brackets
简单应用栈的模拟。先将字符串内已匹配的括号pop掉,剩下的依次储存就好。#include#include#includeusing namespace std;int main() { string str; while (cin >> str) { stack stk1, stk2, stk3; // stk1存'[', stk2临时中转, stk3存']' for原创 2014-12-02 22:50:18 · 312 阅读 · 0 评论 -
Sicily 1373 Cows Of The Round Ta
看了半天题目,好像除了暴力枚举没什么别的方法...而且题目3s,这是在暗示枚举啊...// Problem#: 1373// Submission#: 3311134// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License/原创 2014-12-03 23:34:22 · 301 阅读 · 0 评论 -
Sicily 14513 Aaah!
水得毫无人性#include #include #include using namespace std;int main(){ string a, b; while (cin >> a >> b) { if (a.length() >= b.length()) printf("go\n"); else printf("no\n"); }}原创 2015-05-31 17:09:13 · 315 阅读 · 0 评论 -
Sicily 13981 Cow Baseball
二分查找即可,偷懒直接用了库函数#include #include #include using namespace std;int num[1005];int main(){ int n, sum = 0, i = 0; scanf("%d", &n); while (i != n) cin >> num[i++]; sor原创 2015-06-01 00:06:16 · 443 阅读 · 0 评论 -
Sicily 1920 Divide The Stones
每次最少分出一个,则最后每个堆的 石头数量都是1, 共有sum(a[i])堆。而分出这些石头共需要sum(a[i] - 1)次操作。对这个操作数进行奇偶判断,若为奇数则Alice胜,否则Bob必胜。#include #include #include #include using namespace std;int main(){ int t, n; scanf("%d",原创 2015-06-01 08:58:01 · 332 阅读 · 0 评论 -
Sicily 1686 Happy Children's Day
#include #include #include using namespace std;const int MAXN = 100010;// declaration of the segment treestruct STNode{ int l, r, maxv, maxi; // left bound, right bound, max value, ma原创 2015-06-04 11:25:18 · 332 阅读 · 0 评论 -
Sicily 2005 Lovely Number
正好用到set的特性,如果已经存在,删除掉。// Problem#: 2005// Submission#: 3177025// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativ原创 2014-11-29 10:55:48 · 850 阅读 · 0 评论 -
Sicily 1426 Phone List
如果有某个号码是另一个号码的一部分,则两个号码必定排序后相连。所以拍一下序,然后挨个相邻查找即可// Problem#: 1426// Submission#: 3179459// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported Lice原创 2014-11-29 08:27:01 · 502 阅读 · 0 评论 -
Sicily 1198 Substring
不能直接用algorithm里面的排序,否则b, ba会输出bba,而应当输出bab#include#include#includeusing namespace std;string str[10];bool cmp(string s1, string s2) { return s1 + s2 < s2 + s1;}int main() { int test;原创 2014-11-27 17:19:38 · 330 阅读 · 0 评论 -
Sicily 1486 统计数字
直接map模拟即可,只是输出格式简直天坑。cin cou原创 2014-11-08 20:44:20 · 401 阅读 · 0 评论 -
Sicily 2501 算算式
直接累加会溢出,所以嘛,秦九韶算法就好// Problem#: 2501// Submission#: 3238517// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativeco原创 2014-11-26 11:25:09 · 269 阅读 · 0 评论 -
Sicily 1344 数列
在3~15的范围内,可以证明第k大的项就是将k转化成2进制表示,其2进制表示对应相应次幂的项是否需要累加// Problem#: 1344// Submission#: 2694846// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported原创 2014-11-26 11:18:55 · 334 阅读 · 0 评论 -
Sicily 4960 Identity Checker
直接用栈模拟,“-”顺序别弄错,不然会WA...#include#include#include#includeusing namespace std;int main() { int n; while (cin >> n && n) { stack stk; string str; for (int i =原创 2014-11-26 11:46:12 · 282 阅读 · 0 评论 -
Sicily 1692 Cover
水题,题中恰好提示了8*3的情况,剩下情况直接对8取余,若能整除,则化为原创 2014-11-21 22:45:44 · 448 阅读 · 0 评论 -
Sicily 1641 Binary Searchable
水题,如果一个数比左面的都大,比右面的都小就是Binary Res原创 2014-11-21 22:56:29 · 820 阅读 · 0 评论 -
Sicily 1176 Two Ends
刚开始没发现是DP,想了半天做错了- -,直接上代码#include#include#includeusing namespace std;int n;int num[1005];int sum;int f[1005][1005];int dp(int begin, int end) { if (f[begin][end] == 0) { // 防止重复搜索原创 2014-11-27 15:58:03 · 277 阅读 · 0 评论 -
Sicily 1152 简单的马周游问题[Special judge]
深搜,但是要每一步都搜索时要依照下一步能走到的格子数从小到大进行搜索,不然会超时// Problem#: 1152// Submission#: 3241599// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// U原创 2014-11-27 17:46:37 · 416 阅读 · 0 评论 -
Sicily 1093 Air Express
直接暴力枚举即可// Problem#: 1093// Submission#: 2694482// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/l原创 2014-11-27 20:55:07 · 414 阅读 · 0 评论 -
Sicily 1626 Recursively Palindromic Partitions
动态规划// Problem#: 1626// Submission#: 3252369// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licen原创 2014-11-21 22:44:04 · 387 阅读 · 0 评论 -
Sicily 1624 Cryptoquote
水题,但是注意输出时的判断,区分getline原创 2014-11-21 22:54:25 · 329 阅读 · 0 评论 -
Sicily 1134 积木分发
大一写的代码风格真是糟糕...重写一遍好了#include#include#include#includeusing namespace std;struct Child { int a, b;};bool cmp(const Child& x, const Child& y) { return x.b < y.b;}int main() { int原创 2014-11-27 17:38:16 · 340 阅读 · 0 评论 -
Sicily 1620 SCVs and minerals
直接贪心,如果生产采矿的玩意能在剩余时间里挖到更多的矿,就生产它,原创 2014-11-21 22:52:07 · 446 阅读 · 0 评论 -
Sicily 1687 Permutation
动态规划,对于n个数字,k个<,原创 2014-11-21 22:48:34 · 375 阅读 · 0 评论 -
Sicily 4423 Calculate the Sum
暴力枚举异或操作是会TLE的。按二进制每位的权重拆开,每位上用1出现的数量乘以0出现的数量,再乘以相对应的权, 这其实也就是异或操作中得到1的结果,将它们累加求和即可,结果比较大,用long long储存。// Problem#: 4423// Submission#: 3751511// The source code is licensed under Creative Commons原创 2015-06-04 14:54:55 · 302 阅读 · 0 评论