摘要: Sorting a Three-Valued Sequence IOI'96 - Day 2 Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted have at most three different key values. This happens for instance when we sort medalists of a competition ac 阅读全文
posted @ 2012-08-15 11:59 剑不飞 阅读(444) 评论(0) 推荐(0) 编辑
摘要: Checker ChallengeExamine the 6x6 checkerboard below and note that the six checkers are arranged on the board so that one and only one is placed in each row and each column, and there is never more than one in any diagonal. (Diagonals run from southeast to northwest and southwest to northeast and inc 阅读全文
posted @ 2012-08-13 19:03 剑不飞 阅读(327) 评论(0) 推荐(0) 编辑
摘要: Superprime RibButchering Farmer John's cows always yields the best prime rib. You can tell prime ribs by looking at the digits lovingly stamped across them, one by one, by FJ and the USDA. Farmer John ensures that a purchaser of his prime ribs gets really prime ribs because when sliced from the 阅读全文
posted @ 2012-08-13 14:24 剑不飞 阅读(379) 评论(0) 推荐(0) 编辑
摘要: Prime PalindromesThe number 151 is a prime palindrome because it is both a prime number and a palindrome (it is the same number when read forward as backward). Write a program that finds all prime palindromes in the range of two supplied numbers a and b (5 #include int f[7]={-1,-1,-1,5,-1,-1,-1};//. 阅读全文
posted @ 2012-08-13 11:45 剑不飞 阅读(208) 评论(0) 推荐(0) 编辑
摘要: Ultra-QuickSortTime Limit: 7000MSMemory Limit: 65536KTotal Submissions: 27736Accepted: 9946DescriptionIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted 阅读全文
posted @ 2012-08-11 20:31 剑不飞 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 素数价值Time Limit 3000msMemory Limit 65536Kdescription我们来定义下一个数的素数价值,假设这个数是N(2 #include #include #define N 50003 using namespace std; bool noprime[N]; int prime[N]; int num; int f[N]; void pprim() { memset(noprime,0,sizeof(noprime)); noprime[0]=1;noprime[1]=1; num=0; memset(f,0,sizeof(f)); f[... 阅读全文
posted @ 2012-08-10 11:54 剑不飞 阅读(235) 评论(0) 推荐(0) 编辑
摘要: Number TrianglesConsider the number triangle shown below. Write a program that calculates the highest sum of numbers that can be passed on a route that starts at the top and ends somewhere on the base. Each step can go either diagonally down to the left or diagonally down to the right. 7 ... 阅读全文
posted @ 2012-08-09 20:24 剑不飞 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Arithmetic ProgressionsAn arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb where n=0,1,2,3,... . For this problem, a is a non-negative integer and b is a positive integer.Write a program that finds all arithmetic progressions of length n in the set S of bisquares. The set of 阅读全文
posted @ 2012-08-09 19:27 剑不飞 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 三国之战 Time Limit 1000 Memory Limit 65536 description 在三国某某战争中,魏军要围攻蜀国. ,诸葛亮亲自指挥战争,对抗曹操。现假设诸葛亮有N个大炮,每个大炮都有一个攻击值ai(ai>=0 &&ai=0 && x#include#include#include#define N 100030using namespace std;class node{ public: int l,r; int sum,lazy; bool flag;}root[4*N];int shu[N];void build(int t, 阅读全文
posted @ 2012-08-08 15:12 剑不飞 阅读(182) 评论(0) 推荐(0) 编辑
摘要: H - A Simple Problem with IntegersCrawling in process...Crawling failedTime Limit:5000MS Memory Limit:131072KB64bit IO Format:%I64d & %I64uSubmitStatusDescriptionYou have N integers, A1,A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number 阅读全文
posted @ 2012-08-07 19:30 剑不飞 阅读(123) 评论(0) 推荐(0) 编辑