代码改变世界

随笔档案-2012年5月29日

百度之星资格赛 E题 C++ 与Java

2012-05-29 15:27 by javaspring, 207 阅读, 收藏,
摘要: 题意:中文题,不说了解法:这道题我没有什么好的方法,就是单个判断,话说,这道题考虑的情况好多,wa了7次才过,各种纠结。。。ac代码:#include <iostream> #include <string.h> #include <string> #include <cstdio> using namespace std; int main(){ //freopen("1.txt","r",stdin); int cnt = 1; string ss; char ch[110]; while(gets(c 阅读全文

百度之星资格赛 J题 百度的新大厦

2012-05-29 15:24 by javaspring, 207 阅读, 收藏,
摘要: 题意:中文题,不解释思路:直接解方程就可以了。设电梯一次上升a,一次下降b,总共按按钮n次,设按上升按钮按了x次,则最后电梯的位置是a*x-b*(n-x),求满足该式的最小正数值即可。总共有2000个电梯,枚举每个电梯,找最小值即可。ac代码:#include <iostream> #include <cstdio> #include <string.h> using namespace std; struct house{ int up,down; }hh[2012]; int fun(int x,int y,int n){ int num = (y*n) 阅读全文

js,jquery字符串转换json,兼容各种浏览器

2012-05-29 13:57 by javaspring, 297 阅读, 收藏,
摘要: js,jquery字符串转json、第一种:eval方式解析 function strToJson(str){ var json = eval('(' + str + ')'); return json; } 第二种:new Function形式function strToJson(str){ var json = (new Function("return " + str))(); return json; } 第三种:使用全局的JSON对象function strToJson(str){ return JSON.parse(st... 阅读全文