上一页 1 ··· 8 9 10 11 12 13 下一页
摘要: int v = 0;NSNumber *number= [NSNumber numberWithInt:v]; //将int转换为NSNumberint v = [number intValue]; //将NSNumber转换为int 阅读全文
posted @ 2013-05-23 15:39 OpenSoucre 阅读(314) 评论(0) 推荐(0) 编辑
摘要: 一个try块可以有(1)有一个finally块,无catch块(2)有一个或多个相关的catch块,无finally块(3)包含一个或多个catch块,同时有一个finally块 阅读全文
posted @ 2013-05-22 15:15 OpenSoucre 阅读(158) 评论(0) 推荐(0) 编辑
摘要: // 单行注释/*... */ 块注释/// 说明注释 标识符 说明 <c> 把行中的文本标记为代码,例如:<c>int i=10;</c> <code> 把多行标记为代码 <example> 标记为一个代码示例 <exception> 说明一个异常类(编译器要验证其语法) <include> 包含其他文档说明文件的注释(编译器要验证其语法) <list> 把列表插入到文档说明中 <param> 标记方法的参数(编译器要验证其语... 阅读全文
posted @ 2013-05-22 14:54 OpenSoucre 阅读(2195) 评论(0) 推荐(1) 编辑
摘要: 当程序中需要大量的对某个字符串进行操作时,应该考虑应用StringBuilder类处理该字符串,其设计的目的就是针对大量String操作的一种改进方法,避免产生太多的临时对象 当程序中只是对某个字符串进行一次或几次操作时,采用String类即可 阅读全文
posted @ 2013-05-22 09:33 OpenSoucre 阅读(352) 评论(0) 推荐(0) 编辑
摘要: 在使用String时必须引用using System.String 而string可以直接使用string 与System.String是等价的 阅读全文
posted @ 2013-05-21 09:39 OpenSoucre 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 如果 "??"运算符的左操作数非空,该运算符将返回做操作数,否则返回右操作数int y=x??-1等价于if(x != null ) y=x;else y = -1; 阅读全文
posted @ 2013-05-21 09:30 OpenSoucre 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 生日猜猜猜Time Limit: 3000/1000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 0Accepted Submission(s): 0Problem Description小明对生日十分看重,因为他可以得到祝福,可以和朋友亲人一起分享快乐,可以为自己的人生做一次总结,并且...能够收到好多礼物!不过小明是个神秘的人,不会轻易告诉你他的生日,现在他想到一个办法,让你去猜他的生日是哪一天。小明会告诉你如下三个信息:1. 出生月份和出生日子的最大公约数;2. 出生月份和出生 阅读全文
posted @ 2013-05-18 21:03 OpenSoucre 阅读(259) 评论(0) 推荐(0) 编辑
摘要: Number SequenceTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7731Accepted Submission(s): 3520Problem DescriptionGiven two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 100 阅读全文
posted @ 2013-05-16 20:06 OpenSoucre 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 1017. StaircasesTime limit: 1.0 secondMemory limit: 64 MBOne curious child has a set ofNlittle bricks (5 ≤N≤ 500). From these bricks he builds different staircases. Staircase consists of steps of different sizes in a strictly descending order. It is not allowed for staircase to have steps equal size 阅读全文
posted @ 2013-05-09 10:06 OpenSoucre 阅读(642) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <vector>#include <algorithm>using namespace std;double func(double *a,const int n){ double dp[2]={0},maxv = a[0]; dp[0] = a[0]; for(int i = 1; i < n; i ++ ){ dp[i%2] = max(a[i],dp[(i-1)%2]*a[i]); maxv=max(maxv,dp[i%2]); } return maxv;}int main... 阅读全文
posted @ 2013-04-30 19:39 OpenSoucre 阅读(187) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <vector>#include <algorithm>using namespace std;int MaxSum(int *a, int n){ int maxv = -1<<30,value = 0; for(int i = 0 ; i < n ; i ++ ){ value += a[i]; maxv=max(maxv,value); value=max(0,value); } return maxv;}int main(){ int a[8]={-2,-2... 阅读全文
posted @ 2013-04-30 19:17 OpenSoucre 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 注意分情况求期望(1)只分配一个房间时,也就是人数少于20,对应测试用例1(2)刚好完全分配时,对应测试用例3(3)不能完全分配,最后还剩余的竞技者的数量小于房间数,随机分配 a) 当elly刚好在最后剩余的里面,也就是elly排最后几名,对应测试用例4 b) 当elly不在最后剩余的里面 ,对应测试用例0和2 1 #include <iostream> 2 #include <numeric> 3 #include <vector> 4 #include <string> 5 #include <algorithm> 6 #incl 阅读全文
posted @ 2013-04-29 11:07 OpenSoucre 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 5 using namespace std; 6 7 class EllysCoprimesDiv2{ 8 public: 9 int gcd(int x,int y){10 while(x){11 int r = x;12 x = y%x;13 y=r;14 }15 return y;16 }17 int get... 阅读全文
posted @ 2013-04-28 21:31 OpenSoucre 阅读(344) 评论(0) 推荐(0) 编辑
摘要: 很郁闷的一题,一定要认真读题目,特别注意这句话 Concatenate its elements to obtain one long string,,,一定要理解这句话 1 #include <iostream> 2 #include <string> 3 #include <vector> 4 #include <algorithm> 5 #include <sstream> 6 #include <numeric> 7 using namespace std; 8 9 class EllysRoomAssignmen 阅读全文
posted @ 2013-04-28 21:05 OpenSoucre 阅读(190) 评论(0) 推荐(0) 编辑
摘要: // accumulate example#include <iostream>#include <functional>#include <numeric>using namespace std;int myfunction (int x, int y) {return x+2*y;}struct myclass { int operator()(int x, int y) {return x+3*y;}} myobject;int main () { int init = 100; int numbers[] = {10,20,30}; cout < 阅读全文
posted @ 2013-04-28 19:31 OpenSoucre 阅读(399) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <vector>#include <string>using namespace std;const string vowels = "aeiouy";bool isVowels(char ch){ for(int i = 0; i < vowels.length(); i ++ ) if( vowels[i] == ch) return true; return false;}class EllysNewNickname{public: int getLength(strin 阅读全文
posted @ 2013-04-28 19:00 OpenSoucre 阅读(145) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <vector>#include <cstdio>using namespace std;int main(){ int n; cin >> n; vector<int> neg,zero,pos; int a; for(int i = 0; i < n; i ++ ) { cin >>a; if(a > 0) pos.push_back(a); else if(a < 0) neg.push_back(a); else zero.push_back 阅读全文
posted @ 2013-04-26 01:44 OpenSoucre 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 1007. Code WordsTime Limit: 2.0 secondMemory Limit: 64 MBA transmitter sends over a noisy line some binary code words. The receiver on the other end uses special technique to recover the original words.Every word originally consists of symbols 0 and 1. All words have the same lengthN(4 ≤N≤ 1000). Af 阅读全文
posted @ 2013-04-25 19:15 OpenSoucre 阅读(301) 评论(0) 推荐(0) 编辑
摘要: 1008. Image EncodingTime Limit: 2.0 secondMemory Limit: 64 MBThere are several ways to encode an image. In this problem we will consider two representations of an image. We assume that the image consists of black and white pixels. There is at least one black pixel and all black pixels are connected 阅读全文
posted @ 2013-04-25 17:31 OpenSoucre 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 很郁闷的一题,完全在考数学的不等式题目简化后的公式为 a^3+b^3+c^3+n=(a+b+c)^3,对其进行化简,最后的等式为 (a+b)(a+c)(b+c)=n/3假设 a<=b<=c,(注意求得a,b,c后对其进行排列,原本的a,b,c是没有顺序的)则 (a+b)<=(a+c)<=(b+c)三个数相乘必然有个数小于等于 开n/3的立方,有一个数大于等于开n/3的立方如 xy=n ,则 x <= √n ,y>=√n设 i=(a+b) , j = (a+c), k =(b+c),则 i<=j<=k令 n=n/3枚举 i=2....sqrt(n) 阅读全文
posted @ 2013-04-24 17:00 OpenSoucre 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 显示行数,单词数和字节数wc [options] [file-list]选项 -c 仅仅显示输入中的字节数 -l 仅仅显示输入中的行数 -L 显示输入中最长的行的长度 -m 仅仅显示输入中的字符数 -w 仅仅显示输入中的单词数如 wc -lw file1 file2 file3 阅读全文
posted @ 2013-04-23 15:09 OpenSoucre 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 1014. Product of DigitsTime Limit: 1.0 secondMemory Limit: 64 MBYour task is to find the minimal positive integer number Q so that the product of digits of Q is exactly equal to N.InputThe input contains the single integer number N (0 ≤ N ≤ 109). OutputYour program should print to the output the onl 阅读全文
posted @ 2013-04-23 10:30 OpenSoucre 阅读(398) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <vector>#include <algorithm>#include <string>using namespace std;int main(){ int n,k; cin >>n>>k; string ss; cin >> ss; bool isEnd = false; for(int i = 0; i < n; i ++ ){ if(ss[i+1] == '#'){ int j; for( j =i+1; j <= i 阅读全文
posted @ 2013-04-23 09:14 OpenSoucre 阅读(167) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <vector>#include <algorithm>using namespace std;int main(){ int n; cin >> n; vector<long long> a(n); long long minv = 1<<30; for(int i = 0; i < n; i++) { cin >> a[i]; minv = min(a[i],minv); } int i = 0; for( i = 0; i < n; i 阅读全文
posted @ 2013-04-23 09:13 OpenSoucre 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 很悲剧的一提,重提交的了三次,WA 6,第6测试用例是41000100110101101输出:Draw#include <iostream>#include <vector>#include <algorithm>#include <string>using namespace std;int main(){ long n; cin >>n; string s,t; cin >> s>>t; long ones=0,onet =0,oneshare = 0; for(long i =0; i < 2*n; 阅读全文
posted @ 2013-04-23 09:11 OpenSoucre 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 1013. K-based Numbers. Version 3Time Limit: 2.0 secondMemory Limit: 64 MBLet’s considerK-based numbers, containing exactlyNdigits. We define a number to be valid if itsK-based notation doesn’t contain two successive zeros. For example:1010230 is a valid 7-digit number;1000198 is not a valid number;0 阅读全文
posted @ 2013-04-22 23:12 OpenSoucre 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 1011. ConductorsTime Limit: 2.0 secondMemory Limit: 64 MBBackgroundEveryone making translations from English to Russian knows an English phrase "Naked conductor runs along the bus". It has two very different meanings.ProblemEvery bus in the Ekaterinburg city has a special man (or woman) ca 阅读全文
posted @ 2013-04-22 16:30 OpenSoucre 阅读(308) 评论(0) 推荐(0) 编辑
摘要: 1010. Discrete FunctionTime Limit: 1.0 secondMemory Limit: 64 MBThere is a discrete function. It is specified for integer arguments from 1 to N (2 ≤ N ≤ 100000). Each value of the function is longint (signed long in C++). You have to find such two points of the function for which all points between 阅读全文
posted @ 2013-04-22 11:38 OpenSoucre 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 1009. K-based NumbersTime Limit: 1.0 secondMemory Limit: 64 MBLet’s consider K-based numbers, containing exactly N digits. We define a number to be valid if its K-based notation doesn’t contain two successive zeros. For example:1010230 is a valid 7-digit number;1000198 is not a valid number;0001235 阅读全文
posted @ 2013-04-22 11:00 OpenSoucre 阅读(378) 评论(0) 推荐(0) 编辑
摘要: 搜索过程 搜索按深度优先策略从根开始,当搜索到任一结点时,判断该点是否满足约束条件D(剪枝函数),满足则继续向下深度优先搜索,否则跳过该结点以下的子树(剪枝),向上逐级回溯 阅读全文
posted @ 2013-04-22 09:37 OpenSoucre 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 1073. Square CountryTime Limit: 1.0 secondMemory Limit: 64 MBThere live square people in a square country. Everything in this country is square also. Thus, the Square Parliament has passed a law about a land. According to the law each citizen of the country has a right to buy land. A land is sold in 阅读全文
posted @ 2013-04-22 09:16 OpenSoucre 阅读(254) 评论(0) 推荐(0) 编辑
摘要: 1086. CryptographyTime Limit: 2.0 secondMemory Limit: 64 MBWhile preparing this problem set the jury has run into the following problem: it was necessary to send by e-mail the texts of the problems. As it is well known, e-mail is not reliable, messages are sent not enciphered, there is a danger that 阅读全文
posted @ 2013-04-22 08:56 OpenSoucre 阅读(332) 评论(0) 推荐(0) 编辑
摘要: (1) 判断是否有回路,这个可以用并查集来做,一旦给定的两个节点a,b是属于同一个集合,那么便可以判定有回路(2)看是否只有一个联通分支,这个可以用并查集来做,最终并查集只有一个根节点 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 5 #define MAX 100000 + 5 6 using namespace std; 7 8 int parent[MAX]; 9 bool used[MAX];10 11 void Make_Set(){12 for(int i = 0 阅读全文
posted @ 2013-04-16 10:55 OpenSoucre 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 并查集的三个主要操作:1、Make_Set(x) 把每一个元素初始化为一个集合 初始化后每一个元素的父亲节点是它本身,每一个元素的祖先节点也是它本身(也可以根据情况而变)。 2、Find_Set(x) 查找一个元素所在的集合 查找一个元素所在的集合,其精髓是找到这个元素所在集合的祖先!这个才是并查集判断和合并的最终依据。 判断两个元素是否属于同一集合,只要看他们所在集合的祖先是否相同即可。 合并两个集合,也是使一个集合的祖先成为另一个集合的祖先3、Union(x,y) 合并x,y所在的两个集合 合并两个不相交集合操作很简单: 利用Find_Set找到其中两个集合的祖先,将一个集合的祖先指向另. 阅读全文
posted @ 2013-04-16 09:18 OpenSoucre 阅读(173) 评论(0) 推荐(0) 编辑
摘要: echo命令去掉换行符echo -n "hello world" 阅读全文
posted @ 2013-04-15 23:17 OpenSoucre 阅读(2837) 评论(0) 推荐(0) 编辑
摘要: 删除文件(或文件的连接)rm [options] file-listrm用来删除一个或多个文件的硬链接或符号链接。当将文件的所有硬链接删除后,文件就被删除options -f 不进行询问,直接删除用户不具有写权限的文件 -i 删除每个文件进行询问 -r 递归删除指定目录的内容,包括子目录和目录自身 -v 显示被删除的每个文件的文件名 阅读全文
posted @ 2013-04-15 22:21 OpenSoucre 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 注意此时要将变量加上“”,不然当变量为空时,会出现[: =: unexpected operator 阅读全文
posted @ 2013-04-15 21:18 OpenSoucre 阅读(1761) 评论(0) 推荐(0) 编辑
摘要: 如果程序中test命令不能正常工作,很可能是因为存在test文件与shell中的test命令发生冲突,要想查看系统中是否有一个指定名称的外部命令你可以尝试使用which test这样的命令来检查执行的是哪一个testif test -f filenamethen .............fi或者if [ -f filename ] 必须在[符号和被检查的条件之间留出空格then .............fiif [ -f filename ]; then 如果then和if放在同一行注意分号 .............fi 阅读全文
posted @ 2013-04-15 17:27 OpenSoucre 阅读(467) 评论(0) 推荐(0) 编辑
摘要: $# 传递给程序的总的参数数目$? 上一个代码或者shell程序在shell中退出的情况,如果正常退出则返回0,反之为非0值。$* 传递给程序的所有参数组成的字符串。$- 在Shell启动或使用set命令时提供选项$? 上一条命令执行后返回的值$$ 当前shell的进程号$! 上一个子进程的进程号$@ 所有的参数,每个都用双括号括起$n 位置参数值,n表示位置($1, $2,$3.....)$0 当前shell名 阅读全文
posted @ 2013-04-15 17:08 OpenSoucre 阅读(342) 评论(0) 推荐(0) 编辑
摘要: 用echo命令显示变量内容时,同时显示了在变量名前加一个$符号就能得到变量的内容使用双引号并不影响变量的替换,但使用单引号和反斜杠就不进行变量的替换var=“hello word”echo $varecho "test $var"echo 'test $var'echo \$var#输出hello worldtest hello worldtest $var$var 阅读全文
posted @ 2013-04-15 16:57 OpenSoucre 阅读(235) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 下一页