摘要: 这道题是链表的基本操作,即值val和后继next需要搞清楚,即循环中的temp = temp.next,这个相当于向后滑动一次 第二一个是要对python的函数熟悉,比如str()是将其转化为字符(也可以直接把一个list全部转化为字符串),且python中字符串可以通过‘+’进行拼接,非常方便 另 阅读全文
posted @ 2018-04-23 12:15 kaisadadi 阅读(107) 评论(0) 推荐(0) 编辑
摘要: Humble NumbersFor a given set of K prime numbers S = {p1, p2, ..., pK}, consider the set of all numbers whose prime factors are a subset of S. This set contains, for example, p1, p1p2, p1p1, and p1p2p3(among others). This is the set of `humble numbers' for the input set S. Note: The number 1 is 阅读全文
posted @ 2012-08-04 09:18 kaisadadi 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 给出一个长度不超过200的由小写英文字母组成的字母串(约定;该字串以每行20个字母的方式输入,且保证每行一定为20个)。要求将此字母串分成k份(1<k<=40),且每份中包含的单词个数加起来总数最大(每份中包含的单词可以部分重叠。当选用一个单词之后,其第一个字母不能再用。例如字符串this中可包含this和is,选用this之后就不能包含th)。单词在给出的一个不超过6个单词的字典中。要求输出最大的个数。输入格式第一行有二个正整数(p,k)p表示字串的行数;k表示分为k个部分。接下来的p行,每行均有20个字符。再接下来有一个正整数s,表示字典中单词个数。(1<=s<=6 阅读全文
posted @ 2012-07-31 22:50 kaisadadi 阅读(395) 评论(0) 推荐(0) 编辑
摘要: Farmer John is considering purchasing a new herd of cows. In this new herd, each mother cow gives birth to two children. The relationships among the cows can easily be represented by one or more binary trees with a total of N (3 <= N < 200) nodes. The trees have these properties:The degree of 阅读全文
posted @ 2012-07-29 20:37 kaisadadi 阅读(229) 评论(1) 推荐(0) 编辑
摘要: To brighten up the gala dinner of the IOI'98 we have a set of N (10 <= N <= 100) colored lamps numbered from 1 to N.The lamps are connected to four buttons:Button 1: When this button is pressed, all the lamps change their state: those that are ON are turned OFF and those that are OFF are t 阅读全文
posted @ 2012-07-28 21:57 kaisadadi 阅读(385) 评论(0) 推荐(0) 编辑
摘要: Runaround numbers are integers with unique digits, none of which is zero (e.g., 81362) that also have an interesting property, exemplified by this demonstration:If you start at the left digit (8 in our number) and count that number of digits to the right (wrapping back to the first digit when no dig 阅读全文
posted @ 2012-07-28 14:29 kaisadadi 阅读(321) 评论(0) 推荐(0) 编辑
摘要: Barn RepairIt was a dark and stormy night that ripped the roof and gates off the stalls that hold Farmer John's cows. Happily, many of the cows were on vacation, so the barn was not completely full.The cows spend the night in stalls that are arranged adjacent to each other in a long line. Some s 阅读全文
posted @ 2012-07-15 20:12 kaisadadi 阅读(151) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<iostream> 2 #include<string.h> 3 #include<algorithm> 4 #include<cstdio> 5 #include<cstdlib> 6 #include<cstring> 7 8 using namespace std; 9 10 int n;11 char b[101];12 char bf[101];13 14 15 void change(int i,int k)16 {17 int q=i,e=0,y;18 if(k< 阅读全文
posted @ 2012-07-14 20:49 kaisadadi 阅读(138) 评论(0) 推荐(0) 编辑
摘要: TransformationsA square pattern of size N x N (1 <= N <= 10) black and white square tiles is transformed into another square pattern. Write a program that will recognize the minimum transformation that has been applied to the original pattern given the following list of possible transformation 阅读全文
posted @ 2012-07-14 15:01 kaisadadi 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Milking CowsThree farmers rise at 5 am each morning and head for the barn to milk three cows. The first farmer begins milking his cow at time 300 (measured in seconds after 5 am) and ends at time 1000. The second farmer begins at time 700 and ends at time 1200. The third farmer begins at time 1500 a 阅读全文
posted @ 2012-07-14 12:12 kaisadadi 阅读(155) 评论(0) 推荐(0) 编辑