上一页 1 ··· 3 4 5 6 7 8 9 下一页
摘要: 1022. Poor contestant ProbConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionAs everybody known, “BG meeting” is very very popular in the ACM training team of ZSU.After each online contest, they will go out for “smoking”. Who will be the poor ones that have to BG the others? Of course, the 阅读全文
posted @ 2013-08-05 11:40 中大黑熊 阅读(711) 评论(0) 推荐(0) 编辑
摘要: 1011. Lenny's Lucky LottoConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionLenny likes to play the game of lotto. In the lotto game, he picks a list ofNunique numbers in the range from1toM. If his list matches the list of numbers that are drawn, he wins the big prize.Lenny has a schem 阅读全文
posted @ 2013-07-30 20:48 中大黑熊 阅读(985) 评论(0) 推荐(0) 编辑
摘要: 1010. ZipperConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionGiven three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must stay in its original order. Fo 阅读全文
posted @ 2013-07-24 17:59 中大黑熊 阅读(275) 评论(0) 推荐(0) 编辑
摘要: 1001. AlphacodeConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionAlice and Bob need to send secret messages to each other and are discussing ways to encode their messages: Alice: "Let's just use a very simple code: We'll assign `A' the code word 1, `B' will be 2, and 阅读全文
posted @ 2013-07-19 00:32 中大黑熊 阅读(737) 评论(0) 推荐(0) 编辑
摘要: 我想介绍看到的两种产生随机数组的方法,伪代码如下:第一种:优先级排序法:PERMUTE-BY-SORTING(A)1 n = length[A];2 for i = 1 to n3 do P[i] = RANDOM(1,n*n*n);4 sort A, usng P as sort keys5 return A; 第二种:下标交换法RANDOMIZE-IN-PLACE(A)1 n = length[A];2 for i = 1 to n3 do swap(A[i],A[RANDOM(i,n)]) 阅读全文
posted @ 2013-07-14 11:14 中大黑熊 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 所谓回溯(backtracking)是通过系统地搜索求解问题的方法。这种方法适用于类似于八皇后这样的问题:求得问题的一个解比较困难,但是检查一个棋局是否构成解很容易。不多说,放上n皇后的回溯问题代码://Queens.h#define Queens_H#ifndef Queeens_H#include using namespace std;class Queens{public: Queens(int size); //构造规模为n行n列的空棋盘 bool is_solved() const; //当前棋盘构成解 void print() const; //输出当前棋盘 bool ... 阅读全文
posted @ 2013-07-13 17:44 中大黑熊 阅读(565) 评论(0) 推荐(0) 编辑
摘要: 很简单的一个程序,建议各位初学Java的同学可以试试写写这个程序:import javax.swing.JOptionPane;public class Game{ public static void main(String args[]) { JOptionPane.showMessageDialog(null,"欢迎来到石头——剪刀——布游戏!","石头——剪刀——布游戏", JOptionPane.INFORMATION_MESSAGE); int man,computer; int player,comp; man = computer = 0 阅读全文
posted @ 2013-07-11 00:00 中大黑熊 阅读(654) 评论(0) 推荐(0) 编辑
摘要: 好久没更博了,大三应该有更多的时间写东西。谢谢大家的支持!//Sort_H.h#include #include #include using namespace std;/*宏定义*/#ifndef Sort_H#define Sort_H/* 为了方便后面的桶排序,我们约定所要排列的数均不超过1000*/class Sort{public: Sort(int s); //构造函数,初始化排序的数组 int Size(); void Insertion_sort(); //插入排序 void Selection_sort(); //选择排序 void Merge(int p,int ... 阅读全文
posted @ 2013-07-05 22:16 中大黑熊 阅读(354) 评论(0) 推荐(0) 编辑
摘要: 在做每周一赛的时候,有一道我觉得题目想起来不算特别难,但是实现起来相当烦琐。而且还AC不了,我先po上我自己写的代码(啰嗦死了),勿喷。原题链接:http://soj.me/7530#include <iostream>#include <string>using namespace std;int main(){ string SS[6]; char crosswords[3][3]; string answer; string result; int i,j,k,l,t,m; int symbol; bool judge = false; for(i = 0;i & 阅读全文
posted @ 2013-03-12 19:06 中大黑熊 阅读(1070) 评论(1) 推荐(0) 编辑
摘要: 大家好久不见!开学之初就事多,现在才有空更博文。这次要讨论的是图论,在上课期间我遇到了一个挺有趣的问题,就是给你一个序列看它是否可图。我们先看一看它的几何背景:若对一个非负整数组(d1,d2,...,dn),∑ni=1di=2m,存在一个简单图G,以它为度序列,则称为这个数组是可图的。至于怎么证明一个序列是不是可图的,我们有以下定理(证明过程略)定理:设有非负整数组(d1,d2,...,dn),且),∑ni=1di=2m是一个偶数,n-1>=d1>=d2>=....>=dn,它是可图的充分必要条件为(d2-1,d3-1,...,dd1+1-1,...,dn)是可图的。有 阅读全文
posted @ 2013-03-06 00:29 中大黑熊 阅读(1614) 评论(1) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 下一页