自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(43)
  • 收藏
  • 关注

原创 10110 - Light, more light

 求是否为完全平方数,但是数据有点阴!!!!!  #include #include using namespace std;int main() { long long x; while(cin >> x && x) { long long t = (long long)sqrt((double)x); if(t * t == x) cou

2010-04-09 22:36:00 132

原创 1025 Constructing Roads In JGShining's Kingdom

公共递增子序列,但是需要 O(n*logn) 的算法!特别注意: 若是答案是1 是 road, 大于1 是roads #include using namespace std;#define inf INT_MAXint a[500001];int b[500001];int t;void f(int from, int to, int x) { int m

2010-02-20 20:42:00 161

原创 1521 排列组合

指数母函数!!!!!!因为这道题才知道有这么回事!!!!!实现还是很简单的!但是还是纪念一下!!!!!! #include using namespace std;int a[11][11];int b[11];int c[11];int main() { int n, m; c[0] = 1; for(int i = 1; i <= 10; i

2010-02-20 16:05:00 124

原创 二维线段树

HDU 1823 Luck and Love第一回写二维线段树,虽然MLE了,但是还是把代码留下来做个纪念,毕竟敲这么长的代码也不容易啊!!!!! #include using namespace std;struct node { short h_from; short h_to; short a_from; short a_to; short l_m

2010-02-10 13:57:00 294

原创 457 - Linear Cellular Automata

题目看懂就可以做出来了,问题就是看了两个小时我题目没看懂!!!!! #include using namespace std;int a[10];int b[50][40];int main() { int T; scanf("%d", &T); while(T--) { for(int i = 0; i < 10; i++) scanf("%

2010-02-07 00:02:00 341

原创 10106 - Product

大数乘以大数。贴了n个模板,都是WA,最后用网络上的别人的代码通过的!!!!O__O"… #include #include using namespace std;void mult(char a[],char b[],char c[]) { int len_a = strlen(a),len_b = strlen(b);

2010-02-06 22:46:00 152

原创 424 - Integer Inquiry

大数加法 #include using namespace std;void add(char a[],char b[],char back[]){ int i,j,k,up,x,y,z,l; char *c; if (strlen(a)>strlen(b)) l=strlen(a)+2; else l=strlen(b)+2; c=

2010-02-06 22:17:00 151

原创 2570 迷瘴

贪心,咋看题目以为是背包,但是由于体积是相同的,那么溶度小的开始选择就可以得到最优解了!!!! #include #include using namespace std;int a[200];int main() { int n, v, w, T; scanf("%d", &T); while(T--) { scanf("%d %d %d", &n

2010-02-06 18:52:00 262 1

原创 489 - Hangman Judge

注意 abcd 和 aaaa 应该是You chickened out. #include #include #include using namespace std;int main() { int n; set se; set::iterator it; string str1, str2; bool a[100]; while(scanf(

2010-02-06 17:29:00 205

原创 488 - Triangle Wave

简单题,看懂题目就能搞定。悲剧的是发现pdf 跟网页的题目居然不一样O__O"…网页的题目才是对的!!!! #include using namespace std;int main() { int T; scanf("%d", &T); while(T--) { int n, m; scanf("%d %d", &n, &m); for(

2010-02-06 16:22:00 135

原创 445 - Marvelous Mazes

简单模拟!!!还以为肯定错了,没想到1Y了,O__O"… #include using namespace std;char a[200];int main() { //freopen("1.txt", "r", stdin); while(gets(a)) { int s = strlen(a); int t = 0; for(int i =

2010-02-06 14:02:00 183

原创 1069 Monkey and Banana

动态规划,暴力!!!!O(∩_∩)O~ #include #include using namespace std;struct node { int x; int y; int z;};bool cmp(node a, node b) { if(a.x != b.x) return a.x > b.

2010-02-06 13:17:00 127

原创 1527 取石子游戏

经典的博弈题!!!不懂的可以上网查看“威佐夫博弈”。 #include #include using namespace std;int main() { int n, m; while(scanf("%d %d", &n, &m) != EOF) { if(n == 0 && m == 0) { cout

2010-02-06 13:13:00 111

原创 490 - Rotating Sentences

水题!!!!输入n行字符串,把这些字符串旋转90°。郁闷的3Y,因为一个等号忘打了!!!! #include #include using namespace std;int main() { string str[200]; int t = 1; while(getline(cin, str[t])) { t++; } int maxsi

2010-02-06 13:02:00 291

原创 144. Meeting

概率书上原原本本的例子,要是不会建议去看书!!!! #include #include using namespace std;int main() { int x, y; cin >> x >> y; int t = (y-x) * 60; double z; cin >> z; double a = (t-z)*(t-z); cout <<

2010-02-04 14:01:00 103

原创 130. Circle

特无语。。。。。好不容易做出来了,结果太兴奋了!!!!一个PE(忘记输出第二个值了),一个CE(没贴代码就提交了 o(╯□╰)o  )。 动态规划,算出递推式!!! #include using namespace std;long long a[31];int main() { a[0] = 1; a[1] = 1; for(int i =

2010-02-04 13:45:00 193

原创 172. eXam

明显的并查集题目,第一回写这类型的题目,居然只一次WA,就AC了,RP爆发啊!!!算法我也不知道怎么说,O(∩_∩)O~等哪天真正学会最优的版本时再来写吧!!!! #include using namespace std;int p[201];int rank[201];void MakeSet(int);void Union(int, int);voi

2010-01-30 11:46:00 239

原创 170. Particles

乍看题目还以为是位压缩+广搜,猛然间发现好像位数有点多!!!于是就想到可能有贪心的解法。解法:判断两串的长度是否一样,判断‘+’号跟‘-’号的个数两个串是否一样多,原因很简单,就不说了!然后找出所有符号不同所在的位置,将上串是‘+’,和上串是‘-’的放在不同的数组,两个数组的元素一定一样多,自己想想就知道原因了。求出两个数组中所有下标一样的元素的差的绝对值,并将它们加起来,

2010-01-30 10:36:00 120

原创 181. X-Sequence

因为m范围只到1000, 所以一定很产生循环,所以找到循环节基本就可以搞定了!!!!取值都取最大的话会超出int的范围,因此WA了一次,55555555555555 #include using namespace std;long long a[2000];int main() { long long A, x, y, z, m, k; cin >> A >>

2010-01-29 21:54:00 171

原创 163. Wise King

超水的题目!!!!!! #include using namespace std;int main() { int n, t; cin >> n >> t; int tot = 0; int x, y; for(int i = 1; i <= n; i++) { cin >> x; y = 1; for(int i = 1; i <= t;

2010-01-29 20:52:00 107

原创 231. Prime Sum

两个素数和等于素数,那么其中一个素数必须是2!!!! #include #include using namespace std;const int N = 1000001;const int M = 80000;bool is[N+1];int prm[M];int getprm(int n) { int i, j, k = 0; int s, e

2010-01-29 19:19:00 152

原创 152. Making round

比较费时费力的一种算法,但是比较好想就是了!先求出前面整数的百分值,然后对剩下的小数值进行排序,原先百分数相加跟100相差n,就在小数最大的前n个加1。 #include #include using namespace std;struct node { int id; double data;};bool cmp(node a, node b

2010-01-29 15:23:00 106

原创 146. The Runner

一道很简单的题目!居然3Y!!!由于保留4位小数,所以可以乘以10000,来处理!!!在每输入一组v和t时,注意要及时的与L取模,防止溢出!!!还有就是起点跟终点的距离可能是顺着跑步方向,也可能是逆着跑步方向的!!! #include using namespace std;int main() { long long l; int n; double

2010-01-29 12:39:00 127

原创 276. Andrew's Troubles

超水的题目!!!! #include using namespace std;int main() { int s, p; cin >> s >> p; if(s >= p) cout << 0 << endl; else { int t = p - s; if(t < 300) cout << 1 << endl; else {

2010-01-29 11:41:00 108

原创 175. Encoding

非常简单的二分题,就是写起来有点烦 175.编码令phi(W)为字符串W按以下方法编码的结果:1、如果W长度为1,那么phi(W)就是W2、设W=w1 w2 …… wN 且 K=N/2 (向下取整)3、phi(W)=phi(wN wN-1 …… wK+1)+phi(wK wK-1 …… w1)例如,phi(Ok)=kO,phi(abcd)=cdab。

2010-01-28 12:23:00 147

原创 118. Digital Root

数根跟9同余,发现这个相信其他的都是小意思了 118. 数根时限: 0.50 sec空间: 4096 KB设 f(n) 表示十进制正整数 n 的各位数字之和。如果 f(n) 是一个1位数那么他就是 n 的数根。否则的话 f(n) 的数根就是 n 的数根。举例说明:987的数根是 6(9+8+7=24 2+4=6)。你的任务是算出这样的数的数根: A1*A2*…*

2010-01-27 23:15:00 142

原创 116. Index of super-prime

筛法求素数,然后求出超级素数最后用完全背包搞定! 116. 超级质数索引时限: 0.50 sec空间: 4096 KB设 P1, P2, … ,PN, … 表示质数序列。超级质数是本身是质数,在质数序列中位置也是质数的数。例如,3 是超级质数,但7不是。 超级质数索引是说:当一个数不能表示成若干个(可以只用1个)超级质数的和的时候,他的索引是0。否则索引就等于用

2010-01-27 22:37:00 177

原创 107. 987654321 problem

算出9位数的情况,其他位数的情况可通过9位数得到。通过小程序得到9位数的情况时答案是8。由于用cout, TLE 一次, 郁闷!!!!!! 107. 987654321问题 时间: 0.75 sec空间: 4096 KB对于给定的正整数N求出有多少10进制N位数满足它的平方末尾是987654321。输入包含 N (1<=N<=106)输出

2010-01-26 09:51:00 133

原创 114. Telecasting station

带权中位数 + 二分对那样例特无语!!!!!!(本题是Special Judge 跟样例不一样也能过啦!!!!!) 114. 电视广播站时限: 0.50 sec空间: 4096 KBBerland国家的城市分布在数轴上。国家政府想要建一个新的电视广播站。在进行了很多次调研以后Berland得出了一些结论:每一个城市的不愉快值等于城市人口乘上城市与广播站的距离

2010-01-25 18:31:00 190

原创 104. Little shop of flowers

动态规划 104.小花店 时间: 0.50 sec. 空间: 4096 KB题目描述你现在想用最令人满意的方案来装饰你花店的橱窗。你有 F 束花, 每束花种类不同, 种数不超过窗台上的花瓶总数。花瓶被嵌入窗台,并且被顺序从1到 V 编号。V 表示花瓶总数。顺序编号使得1号花瓶在最左边, V 号花瓶在最右边。花束是可以移动的,而且按照不同种类从1 到 F 编号

2010-01-25 11:55:00 187

原创 113. Nearly prime numbers

 筛法+两次遍历 113. 亚质数时限: 0.50 sec空间: 4096 KB亚质数可以表示成两个质数的积的正整数。在一个给出的长度为 N 的正整数序列中,你需要用 "Yes" 和 "No" 来判断序列中的每一个数是不是亚质数。输入包含 N+1 个正整数。第一个数是 N (1<=N<=10)。后 N 个数表示序列,均不超过 109 。数字被

2010-01-24 00:19:00 182

原创 133. Border

排序+O(n)扫一遍。注意 Aji and Bij  没有等号哦!!!!!133. 边界时间限制: 0.50 sec空间限制: 4096 KB 在A和B的边界出有N个前哨站。对于每一个前哨站 k,他的管辖范围[Ak,Bk]是已知的。由于经济原因,A国总统决定减少一些前哨站。多余的前哨站都会被抛弃。我们定义i号前哨站是多余的如果存在另一个前哨战j满足 Aj<Ai 且 Bi

2010-01-22 14:15:00 120

原创 126. Boxes

好题目啊!!!!!模拟加剪枝!!!!!题目大意:时间限制: 0.50 sec空间限制: 4096 KB 现在你有两个盒子,第一个盒子中有A个小球,第二个中有B个小球。(0 < A + B < 2147483648)。小球可以从一个盒子被拿到另一个盒子,但是每次从一个盒子拿到另一个盒子的小球的数量必须等于另一个盒子中小球的数量。你需要弄清是否能在若干次操作后将所有的小球移

2010-01-22 12:49:00 114

原创 SGU 184. Patties

超水题!!!!!!! #include using namespace std;int main() { int a, b, c; int d, e, f; cin >> a >> b >> c; cin >> d >> e >> f; int x = a/d; int y = b/e; int z = c/f; int minx = x;

2010-01-21 20:42:00 157

原创 SGU 127. Telephone directory

看懂题目!!!!!! #include using namespace std;int main() { int k, n; int a[10] = {0}; scanf("%d %d", &k, &n); int temp; for(int i = 1; i <= n; i++) { scanf("%d", &temp); a[temp/100

2010-01-21 20:17:00 288

原创 SGU 112. a^b-b^a

模拟,大数乘法,大数减法 #include #include using namespace std;void mult(char a[],char b[],char s[]){ int i,j,k=0,alen,blen,sum=0,res[300][300]={0},flag=0; char result[300]; alen=strlen(a);ble

2010-01-21 19:49:00 357

原创 UVA 414 - Machined Surfaces

题目大意:不断地消除空格,使左右两边接触,求最后剩下多少个空格。 #include using namespace std;int main() { int n; int a[15]; char c; while(scanf("%d", &n) != EOF && n) { for(int i = 1; i <= n; i++) a[i] = 0;

2010-01-21 15:06:00 134

原创 UVA 102 - Ecological Bin Packing

枚举注意输入顺序是B G C   输出是按照 B C G顺序的 #include using namespace std;int main() { int a[10]; int b[7]; while(scanf("%d", &a[1]) != EOF) { int tot = 0; tot += a[1]; for(int i = 2; i

2010-01-21 15:04:00 153

原创 SGU 115. Calendar

简单模拟日期 #include using namespace std;int main() { int d, m; cin >> d >> m; int a[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; if(m > 12 || m <= 0) { cout << "Impossib

2010-01-21 14:59:00 125

原创 SGU 135. Drawing Lines

线切割空间,推出公式搞定 #include using namespace std;int main() { long long n; cin >> n; cout << n * (n+1) / 2 + 1 << endl; return 0;}

2010-01-21 14:56:00 182

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除