上一页 1 ··· 6 7 8 9 10 11 12 13 下一页
摘要: #include #include #include using namespace std;int main(){ int n; cin >> n; vector a(n); for(int i = 0 ; i > a[i]; int maxlen = 0; if(n == 1) maxlen = 1; else if(n == 2) maxlen = 2; else{ maxlen = 2; int l = 0, r =1; for(int i = 2; i < n; ++ i){ ... 阅读全文
posted @ 2013-11-24 21:08 OpenSoucre 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 主要参考下面两篇论文1、《不定方程x(x-1)=Dy(y-1)的解法》2、《用递推公式求一个不定方程的正整数解》原有题目意思是记得有一次全班去唱K, 其中有个活动是情歌对唱. 具体操作流程是这样的:准备好 21 个阄(我们班 15 男 6 女), 其中只有两个是有标记的, 每人随意抓取一个, 最后取到有标记的阄的两个人去点首情歌对唱.旁边一哥们儿幽幽地对我说, 看来搅基真是神的安排啊, 你看我们班的男女人数, 搅基的几率 C(15,2)/C(21,2) 刚好是 1/2.给跪了, 这哥们儿对数字太敏感了, 简直是拉马努金转世啊. 不过我随之想到一个问题: (21, 15) 真的是神的唯一安排吗? 阅读全文
posted @ 2013-11-24 18:21 OpenSoucre 阅读(1038) 评论(0) 推荐(0) 编辑
摘要: str = @(num) 直接将num转换为字符串 阅读全文
posted @ 2013-11-22 16:14 OpenSoucre 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 条件运算符val1!=0 ? val1:val2 等价于 val1?val2 阅读全文
posted @ 2013-11-22 16:11 OpenSoucre 阅读(271) 评论(0) 推荐(0) 编辑
摘要: 今天在阅读chipmunk2D源码时,在cpBB.h中看到了一个判读矩阵相交的函数static inline cpBool cpBBIntersects(const cpBB a, const cpBB b){ return (a.l b.l || a.t b.t); }还有一种方法就是根据两个矩阵相交形成的矩阵判断,两个矩阵相交的结果一定是一个矩阵,构成相交矩阵为CRect{newLeft,newBottom,newRight,newTop}newLeft = max(a.l,b.l)newBottom = max(a.t,b.t)newRight... 阅读全文
posted @ 2013-11-19 11:55 OpenSoucre 阅读(2274) 评论(0) 推荐(0) 编辑
摘要: #include #include const double eps = 1e-10;struct Point{ double x,y; Point(double x = 0, double y = 0):x(x),y(y){} //初始化列表构造函数};typedef Point Vector;//向量+向量 = 向量, 点 + 向量 = 向量Vector operator + (Vector A, Vector B){return Vector(A.x+B.x, A.y+B.y);}//点-点=向量Vector operator - (Point A,Point B){retu... 阅读全文
posted @ 2013-11-18 00:29 OpenSoucre 阅读(328) 评论(0) 推荐(0) 编辑
摘要: (1)应用应该对用户程序持ipad的变化做出响应(2)要设计出确实出色的触摸屏交互界面需要能够触摸到自己的设计,反复触摸,直到找到感觉(3)chipmunk physics 2D的物理图形库(4)不断的问自己“我能通过30秒的youtube视频卖出这个应用吗”(5)http://www.imdb.com/ 检查电影上映日期(6)如果想在iPad上设计出最畅销的游戏,必须考虑如何充分利用加速传感器和触摸屏(7)困难的部分通常不在于找到时间开发应用,而在于抵抗想要做些别的事情的诱惑(8)最棒的应用软件设计应该先用笔和纸完成,然后再用photoshop(9)用google docs做项目协同(10) 阅读全文
posted @ 2013-11-16 23:32 OpenSoucre 阅读(404) 评论(0) 推荐(0) 编辑
摘要: 每当运行程序时,左下角的FPS就低到了10,使app很卡,原来程序主要卡的部分-(void)draw{ NSDate *startTime = [NSDate date]; [self func]; //func为调用的函数 NSLog(@"time:%f",-[startTime timeIntervalSinceNow]);}结果显示的时间远远超过了1.0/60,(1.0/60为AppDelegate.m中的[director_setAnimationInterval:1.0/60] 设置的FPS)由于[self func]比较耗时超过了1.0/60,故考虑将函数fun 阅读全文
posted @ 2013-11-15 14:12 OpenSoucre 阅读(720) 评论(0) 推荐(0) 编辑
摘要: def find_defining_class(obj, method_name): for ty in type(obj).mro(): if method_name in ty.__dict__: return ty return Nonemro方法用来获得用于搜索调用方法的类对象列表 阅读全文
posted @ 2013-11-13 23:45 OpenSoucre 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 如果不清楚一个对象是否拥有某个属性,可以使用内置函数hasattr访问一个对象的属性的方法是通过特别属性__dict__,它是一个映射,将属性名称映射到属性值为了调试方便,可以添加下面这个函数 def print_attributes(self): for attr in self.__dict__: print attr,getattr(self,attr) 阅读全文
posted @ 2013-11-13 23:20 OpenSoucre 阅读(756) 评论(0) 推荐(0) 编辑
摘要: myView.clipsToBounds = YES; 阅读全文
posted @ 2013-11-12 12:10 OpenSoucre 阅读(362) 评论(0) 推荐(0) 编辑
摘要: 题目id: 1 just print a+bgive you two var a and b, print the value of a+b, just do it!!print a+b题目id: 2 list排序给你一个list L, 如 L=[2,8,3,50], 对L进行升序排序并输出print sorted(L)题目id: 3 字符串逆序给你一个字符串 a, 如a=‘12345’,对a进行逆序输出a。print a[::-1]题目id:4 输出字典key给你一字典a,如a={1:1,2:2,3:3},输出字典a的key,以','链接,如‘1,2,3'。print 阅读全文
posted @ 2013-11-09 20:52 OpenSoucre 阅读(6596) 评论(7) 推荐(1) 编辑
摘要: zip是一个内置函数, 接受两个或多个序列,并将他们拉到一起,成为一个元组列表。每个元组包含各个序列中的一个元素。s = 'abc' t = [0,1,2]zip(s,t) >>>[('a',0),('b',1),('c',2)] 如果需要遍历序列中的元素以及它们的下标,可以使用内置函数enumerate: for index,elemet in enumerate('abc'): print index,element>>> 0 a 1 b 2 c 阅读全文
posted @ 2013-11-06 14:57 OpenSoucre 阅读(353) 评论(0) 推荐(0) 编辑
摘要: chr()根据整数返回对应的字符,也就是讲ascii转换为字符unichr()将整数返回成unicode字符ord()将字符转换成ascii码 阅读全文
posted @ 2013-11-06 12:33 OpenSoucre 阅读(3379) 评论(0) 推荐(0) 编辑
摘要: CGImageRef imgRef = [image CGImage]; 通过此种方式的得到的CGImageRef不能利用CGImageRelease释放,因为你不拥有它所以不用释放在ios中特定形状剪裁图片的实现(注意要释放内存,不然即使用ARC也会出现内存泄露)- (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)mask{ CGImageRef imgRef = [image CGImage]; CGImageRef maskRef = [mask CGImage]; CGImageRef actual... 阅读全文
posted @ 2013-11-04 17:19 OpenSoucre 阅读(626) 评论(0) 推荐(0) 编辑
摘要: 看完博客http://blog.jobbole.com/24393/的有关读书知识打想法,我感觉以前的经典书籍都白读了,有一句说的不错“读的太快或太慢,都一无所获”以前读经典书籍就想几天之内把书看完,而当看完时感觉自己什么也不会,感觉还是没把书读细致,没有认真思考参照其博客给自己以后读书定几条:(1)要一口气读完,不能断断续续,每天坚持读一点(2)边读边思考,还要做完课后习题,同时网上查阅相关的内容(3)每章读完,写一篇读书笔记,记录自己的想法(4)重复的读一些经典的书籍 阅读全文
posted @ 2013-11-04 11:25 OpenSoucre 阅读(289) 评论(0) 推荐(0) 编辑
摘要: pstree 显示当前运行的所有进程及相关子进程tree 以树式的格式得到当前文件夹的结构curl ifconfig.me 获得外部的IP地址last 显示上次用户登陆的历史信息sudo !!没有特定输入sudo命令而运行,将给出没有权限的错误。那么,你不需要重写整个命令,仅仅输入’!!‘就可以抓取最后的命令。ctrl+x+e 快速打开编辑器 阅读全文
posted @ 2013-11-04 11:01 OpenSoucre 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int check(int a, int b){ 8 if(a - b > 0 )return 1; 9 else if(a-b > n;16 vector x(n);17 for(int i = 0; i > x[i];18 int i;19 for( i = 3; i = n) cout<<"no"<<endl;34 } 阅读全文
posted @ 2013-10-28 20:52 OpenSoucre 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int main(){ 8 int n; 9 cin >> n;10 string words = "> tmp;13 words +=tmp+"> message;17 if(message.length() = message.length()){cout<<"no"<<endl; return 0;}23 else ++i;24 }25 cout<<"... 阅读全文
posted @ 2013-10-28 19:53 OpenSoucre 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 4 using namespace std; 5 6 class TheArithmeticProgression{ 7 public: 8 double minimunChange(int a,int b, int c){ 9 return (abs(2*b-a-c)+0.0)/2;10 }11 12 }; 阅读全文
posted @ 2013-10-19 22:38 OpenSoucre 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #include 5 #define LL long long 6 7 using namespace std; 8 9 class LittleElephantAndPermutationDiv2{10 public:11 LL getNumber(int N, int k){12 LL res = 0;13 vector a(N);14 for(int i = 0 ; i = k ) ++res;23 copy(a.begi... 阅读全文
posted @ 2013-10-19 22:18 OpenSoucre 阅读(339) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 class WolfDelaymaster{ 8 public: 9 bool checkChar(string str, char c, int start ,int num){10 for(int i = start; i < start + num; ++ i ){11 if(str[i] != c) return false;12 }13 return true;14 ... 阅读全文
posted @ 2013-10-19 22:02 OpenSoucre 阅读(302) 评论(0) 推荐(0) 编辑
摘要: 此题主要考查的是求最长公共子序列设A[i]:A[j] = a:b = ac:bc B[ii]:B[jj] = c:d = ac:ad ,如果A[i]:A[j] = B[ii]:B[jj]则bc= ad,所以A乘以B的倍数,B乘以A的倍数,则A与B所求的序列必然是一样的,即求A与B的最长公共子序列 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 class AstronomicalRecordsEasy{ 8 public: 9 int minimalPlanets(vector A, vecto... 阅读全文
posted @ 2013-10-19 21:21 OpenSoucre 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 暴力枚举 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 class FoxAndClassroom{ 8 public: 9 string ableTo(int n , int m){10 for(int i = 0 ; i > visitFlag(n,vector(m,false));13 int kx = i ,ky = j,count = 0;14 while(!visitFlag[kx][ky]){15 ... 阅读全文
posted @ 2013-10-19 20:05 OpenSoucre 阅读(265) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 4 using namespace std; 5 6 int main(){ 7 int m,sum = 0; 8 cin >> m ; 9 vector c(m+1,0);10 for(int i = 1; i > c[i];sum+=c[i];}11 int x,y,firstPart = 0, secondPart = 0,firstIndex = 0, secondIndex =0;12 cin >> x >> y;13 for(firstIndex = 0,secon... 阅读全文
posted @ 2013-10-19 14:29 OpenSoucre 阅读(212) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;class RaiseThisBarn{public: int calc(string str){ int num = count(str.be... 阅读全文
posted @ 2013-10-14 23:33 OpenSoucre 阅读(176) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;int main(){ int k,d; cin >> k >>d; if(d==0) { k > 1 ? (cout<<"No solution"<<endl):(cout<<0<<endl); } else{ cout<<d; for(int i = 1 ; i < k; ++ i) cout<<0; cout<<endl; }} 阅读全文
posted @ 2013-10-14 22:11 OpenSoucre 阅读(184) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;int main(){ int n,m; cin >> n >> m; int minCorrectTime =1000, maxCorrectTime = 0, minWrongTime = 1000,tmp; for(int i = 0 ; i > tmp; minCorrectTime = min(tmp,minCorrectTime); maxCorrectTime = max(tmp,maxCorrectTime); } for(int i =... 阅读全文
posted @ 2013-10-10 14:43 OpenSoucre 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 主要原因是某部分内存释放的太频繁,解决方法是检查函数的中[xxx release]; 将其注释掉 就行了 阅读全文
posted @ 2013-10-08 14:35 OpenSoucre 阅读(5118) 评论(0) 推荐(0) 编辑
摘要: 因为数字只含有5或0,如果要被90整除的话必须含有0,否则输出-1 如果含有0的话,就只需考虑组合的数字之和是9的倍数,只需要看最大的5的个数能否被9整数#include #include using namespace std;int main(){ int n; cin >> n; int numOfZero = 0, numOfFive = 0,tmp; for(int i = 0 ; i >tmp; ( tmp == 5 ) ? (++numOfFive) : (++numOfZero); } if(numOf... 阅读全文
posted @ 2013-10-07 23:48 OpenSoucre 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 class LittleElephantAndBooks{ 8 public: 9 int getNumber(vector pages,int number){10 sort(pages.begin(),pages.end());11 int res = pages[number];12 for(int i = 0; i < number-1; i ++ ){13 res +=... 阅读全文
posted @ 2013-09-27 22:30 OpenSoucre 阅读(246) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;int main(){ int n; cin >> n; vector a(n); for(int i = 0 ; i >a[i]; sort(a.begin(),a.end()); swap(a[0],a[n-1]); for(int i = 0 ; i < n; ++i) cout<<a[i]<<" "; cout<<endl; return 0;} 阅读全文
posted @ 2013-09-21 23:42 OpenSoucre 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 注意题目的数字最大是7 而能整除的只有 1,2,3,4,6,故构成的组合只能是1,2,4 或1,2,6或1,3,6,故分别统计1,2,3,4,6的个数,然后再分配 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 int main(){ 9 int n;10 cin >> n ;11 vector a1,a2,a3,a4,a6;12 int tmp;13 for(int i = 0 ; i >tmp;15 if(tmp != 1 &... 阅读全文
posted @ 2013-09-11 23:04 OpenSoucre 阅读(204) 评论(0) 推荐(0) 编辑
摘要: #define SuppressPerformSelectorLeakWarning(Stuff) \ do { \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \ Stuff; \ _Pragma("clang diagnostic pop") \ } while (0)SuppressPerformSelectorLeakWarning( [_targ 阅读全文
posted @ 2013-08-29 16:23 OpenSoucre 阅读(267) 评论(0) 推荐(0) 编辑
摘要: CCRenderTexture *renderTexture;[renderTexture getUIImage]; 阅读全文
posted @ 2013-08-16 17:26 OpenSoucre 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 简单的题目class KeyDungeonDiv2{public: int countDoors(vector doorR, vector doorG, vector keys) { int res = 0; for(int i = 0 ; i < doorR.size(); i ++){ if(doorR[i] <= keys[0]+keys[2] && doorG[i] <= keys[1]+keys[2] && doorR[i] + doorG[i] <=keys[0]+keys[1]+keys[2]) res ++;... 阅读全文
posted @ 2013-08-14 20:05 OpenSoucre 阅读(333) 评论(0) 推荐(0) 编辑
摘要: 当xcode编译时出现这个错误,一般是你的编译源码中存在重复的源码解决方法:"Build Phases" -> "Compile Sources" 去删除重复的类 同时删除重复的库 阅读全文
posted @ 2013-08-12 15:51 OpenSoucre 阅读(295) 评论(0) 推荐(0) 编辑
摘要: for_each有一个独门绝技,其他算法没有,那就是可以返回值来获取函数的状态#include #include #include using namespace std;class MeanValue{ private: long num; long sum; public: MeanValue():num(0),sum(0){} void operator() (int elem){ num ++ ; sum += elem; } double value(){ return static_cast(sum)... 阅读全文
posted @ 2013-08-11 23:05 OpenSoucre 阅读(463) 评论(0) 推荐(0) 编辑
摘要: typedef std::map StringFloatMap; StringFloatMap col1; StringFloatMap::iterator pos; for(pos = col1.begin();pos!=col1.end();){ if(pos->second == value) col1.erase(pos++); else{ ++pos; } } 阅读全文
posted @ 2013-08-09 21:59 OpenSoucre 阅读(2793) 评论(0) 推荐(0) 编辑
摘要: (1)运用value_typestd::map col1;col1.insert(std::map::value_type("aaa",22.3)); (2)运用pairstd::map col1;col1.insert(std::pair("aaa",22.3)); (3) 运用make_pair()std::map col1;col1.insert(std::make_pair("aaa",22.3)); 阅读全文
posted @ 2013-08-09 21:56 OpenSoucre 阅读(312) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 下一页