04 2012 档案
摘要:Prime Ring ProblemTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12105Accepted Submission(s): 5497Problem DescriptionA ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of nu
阅读全文
摘要:SafecrackerTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3966Accepted Submission(s): 2028Problem Description=== Op tech briefing, 2002/11/02 06:42 CST === "The item is locked in a Klein safe behind a painting in the second-floor library. Kle
阅读全文
摘要:Tempter of the BoneTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 33445Accepted Submission(s): 9015Problem DescriptionThe doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, a
阅读全文
摘要:Little Bishops A bishop is a piece used in the game of chess which can only move diagonally from its current position. Two bishops attack each other if one is on the path of the other. In the figure below, the dark squares represent the reachable locations for bishop B1 from its current position. Bi
阅读全文
摘要:The Tourist Guide Mr. G. works as a tourist guide in Bangladesh. His current assignment is to show a group of tourists a distant city. As in all countries, certain pairs of cities are connected by two-way roads. Each pair of neighboring cities has a bus service that runs only between those two citie
阅读全文
摘要:Playing with Wheels Consider the following mathematical machine. Digits ranging from 0 to 9 are printed consecutively (clockwise) on the periphery of each wheel. The topmost digits of the wheels form a four-digit integer. For example, in the following figure the wheels form the integer 8,056. Each w
阅读全文
摘要:Bicoloring The four-color theoremstates that every planar map can be colored using only four colors in such a way that no region is colored using the same color as a neighbor. After being open for over 100 years, the theorem was proven in 1976 with the assistance of a computer.Here you are asked to
阅读全文
摘要:Fire NetTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3036Accepted Submission(s): 1751Problem DescriptionSuppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a st
阅读全文
摘要:FatMouse' TradeTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 22453Accepted Submission(s): 6992Problem DescriptionFatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBea
阅读全文
摘要:喷水装置(二)时间限制:3000 ms | 内存限制:65535 KB难度:4描述有一块草坪,横向长w,纵向长为h,在它的橫向中心线上不同位置处装有n(n<=10000)个点状的喷水装置,每个喷水装置i喷水的效果是让以它为中心半径为Ri的圆都被润湿。请在给出的喷水装置中选择尽量少的喷水装置,把整个草坪全部润湿。输入第一行输入一个正整数N表示共有n次测试数据。每一组测试数据的第一行有三个整数n,w,h,n表示共有n个喷水装置,w表示草坪的横向长度,h表示草坪的纵向长度。随后的n行,都有两个整数xi和ri,xi表示第i个喷水装置的的横坐标(最左边为0),ri表示该喷水装置能覆盖的圆的半径。输
阅读全文
摘要:开心的小明时间限制:1000 ms | 内存限制:65535 KB难度:4描述小明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间。更让他高兴的是,妈妈昨天对他说:“你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过N 元钱就行”。今天一早小明就开始做预算,但是他想买的东西太多了,肯定会超过妈妈限定的N 元。于是,他把每件物品规定了一个重要度,分为5 等:用整数1~5 表示,第5 等最重要。他还从因特网上查到了每件物品的价格(都是整数元)。他希望在不超过N 元(可以等于N 元)的前提下,使每件物品的价格与重要度的乘积的总和最大。设第j 件物品的价格为v[j],
阅读全文
摘要:回文字符串时间限制:3000 ms | 内存限制:65535 KB难度:4描述所谓回文字符串,就是一个字符串,从左到右读和从右到左读是完全一样的,比如"aba"。当然,我们给你的问题不会再简单到判断一个字符串是不是回文字符串。现在要求你,给你一个字符串,可在任意位置添加字符,最少再添加几个字符,可以使这个字符串成为回文字符串。输入第一行给出整数N(0<N<100)接下来的N行,每行一个字符串,每个字符串长度不超过1000.输出每行输出所需添加的最少字符数样例输入1Ab3bd样例输出2分析:d[i][j]表示从第 i 到第 j 的最优解;if(a[i]==a[j]
阅读全文
摘要:括号匹配(二)时间限制:1000 ms | 内存限制:65535 KB难度:6描述给你一个字符串,里面只包含"(",")","[","]"四种符号,请问你需要至少添加多少个括号才能使这些括号匹配起来。如:[]是匹配的([])[]是匹配的((]是不匹配的([)]是不匹配的输入第一行输入一个正整数N,表示测试数据组数(N<=10)每组测试数据都只有一行,是一个字符串S,S中只包含以上所说的四种字符,S的长度不超过100输出对于每组测试数据都输出一个正整数,表示最少需要添加的括号的数量。每组测试输出占一行样例输入4
阅读全文
摘要:字符串的输入的主流函数:一、scanf(); 二、cin; 三、gets(); 四、getline(); 五、sscanf()。一、scanf("%s",str);遇见空格或换行就停止。#include<stdio.h>int main(){ char str[100]; while(true) {scanf("%s",str); printf("%s\n",str);} return 0;}输入:123 456输出:123 456二、cin>>str;与scanf();相似遇见空格或换行就停止;以文件结束。三
阅读全文
摘要:前缀式计算时间限制:1000 ms | 内存限制:65535 KB难度:3描述先说明一下什么是中缀式:如2+(3+4)*5这种我们最常见的式子就是中缀式。而把中缀式按运算顺序加上括号就是:(2+((3+4)*5))然后把运算符写到括号前面就是+(2 *( +(3 4) 5) )把括号去掉就是:+ 2 * + 3 4 5最后这个式子就是该表达式的前缀表示。给你一个前缀表达式,请你计算出该前缀式的值。比如:+ 2 * + 3 4 5的值就是 37输入有多组测试数据,每组测试数据占一行,任意两个操作符之间,任意两个操作数之间,操作数与操作符之间都有一个空格。输入的两个操作数可能是小数,数据保证输入的
阅读全文
摘要:最长公共子序列时间限制:3000 ms | 内存限制:65535 KB难度:3描述咱们就不拐弯抹角了,如题,需要你做的就是写一个程序,得出最长公共子序列。tip:最长公共子序列也称作最长公共子串(不要求连续),英文缩写为LCS(Longest Common Subsequence)。其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的,则 S 称为已知序列的最长公共子序列。输入第一行给出一个整数N(0<N<100)表示待测数据组数接下来每组数据两行,分别为待测的两组字符串。每个字符串长度不大于1000.输出每组测试数据输出一个整数,表示最长
阅读全文
摘要:The Triangle时间限制:1000 ms | 内存限制:65535 KB难度:4描述73 88 1 02 7 4 44 5 2 6 5(Figure 1)Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers 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 o
阅读全文
摘要:单调递增最长子序列时间限制:3000 ms | 内存限制:65535 KB难度:4描述求一个字符串的最长递增子序列的长度如:dabdbf最长递增子序列就是abdf,长度为4输入第一行一个整数0<n<20,表示有n个字符串要处理随后的n行,每行有一个字符串,该字符串的长度不会超过10000输出输出字符串的最长递增子序列的长度样例输入3aaaababcabklmncdefg样例输出137分析:方法一:求最大字段和的方法相似。O(n^2)dp[i] 以 i 结尾的当然也包括i 在内的最长递增子序列;我经常犯的的一个错误是:dp[i] = d[j] +1(j<i &&
阅读全文
摘要:一、hash函数基础1 1、一个简单的hash函数:/*key为一个字符串,nTableLength为哈希表的长度该函数得到的hash值分布比较均匀*/long long getHashIndex(char *key,long longnTableLength ){long longnHash = 0; while (*key) { nHash = (nHash<<5) + nHash + *key++; } return ( nHash % nTableLength );}2、一个完整测试程序: 哈希表的数组是定长的,如果太大,则浪费,如果太小,体现不出效率。合适的数组大小是哈.
阅读全文
摘要:Humble NumbersTime Limit: 2 Seconds Memory Limit: 65536 KBA number whose only prime factors are 2,3,5 or 7 is called a humblenumber. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.Write a program to find and print the nth el.
阅读全文
摘要:LottoTime Limit: 2 Seconds Memory Limit: 65536 KBIn a Lotto I have ever played, one has to select 6 numbers from the set {1,2,...,49}. A popular strategy to play Lotto - although it doesn't increase your chance of winning - is to select a subset S containing k (k>6) of these 49 numbers, and t
阅读全文
摘要:求f(n)%p描述:f(0)=1;f(1)=1;f(2)=2;f(n)=f(n-1)+f(n-2);输入:两个整数n和p;输出:f(n)%p;方法一:矩阵快速模幂struct SS{int S[2][2];}A;A.S[0][0]=0;A.S[0][1]=1;A.S[1][0]=1;A.S[1][1]=1;A=A^n;f(n)=A.S[1][1];1、C++递归实现(这个方法是我常用的):View Code 1 #include<iostream> 2 using namespace std; 3 4 struct SS{int S[2][2];}; 5 int n=2,p; 6
阅读全文
摘要:Sexagenary CycleTime Limit: 2 Seconds Memory Limit: 65536 KBThe Chinese sexagenary cycle, also known as the stems-and-branches, is a cycle of sixty terms used for recording days or years. Each term in the sexagenary cycle consists of two Chinese characters, the first representing a term from a cycl.
阅读全文
摘要:NimTime Limit: 3 Seconds Memory Limit: 65536 KBNim is a mathematical game of strategy in which two players take turns removing objects from distinct heaps. The game ends when one of the players is unable to remove object in his/her turn. This player will then lose. On each turn, a player must remov.
阅读全文
摘要:Max SumTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 72615Accepted Submission(s): 16626Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max
阅读全文
摘要:完全覆盖时间限制:2000 ms | 内存限制:65535 KB难度:3描述有一天小董子在玩一种游戏----用2*1或1*2的骨牌把m*n的棋盘完全覆盖。但他感觉游戏过于简单,于是就随机生成了两个方块的位置(可能相同),标记一下,标记后的方块不用覆盖。还要注意小董子只有在m*n的棋盘能被完全覆盖后才会进行标记。现在他想知道:如果标记前m*n的棋盘能被完全覆盖,标记后的棋盘是否能被完全覆盖?输入第一行有一个整数t(1<=t<=100000),表示有t组测试数据。每组测试数据有三行或一行。第一行有两个整数 m,n(1<=m,n<=25535)表示行数和列数。第二、三行都有两
阅读全文
摘要:Kiki & Little Kiki 2时间限制:3000 ms | 内存限制:65535 KB难度:4描述There are n lights in a circle numbered from 1 to n. The left of light 1 is light n, and the left of light k (1< k<= n) is the light k-1.At time of 0, some of them turn on, and others turn off.Change the state of light i (if it's on
阅读全文

浙公网安备 33010602011771号