摘要: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 /* 7 *对于多项式的,我们可以用一个二进制数来表示进行减法 8 *例如:x^3+x+1 可以以二进制数1011来表示,即十进制数的11 9 *本题给定既约多项式 x^8+x^4+x^3+x+1 可以通过用二进制数100011011来表示 10 *即十进制数283 11 *因此其生成的有限域GF(2^8)/(x^8+x^4+x^3+x+1),共有2^8=256个元素 12 */ 13 14 //定义一些常量 15 c... 阅读全文
posted @ 2013-10-28 17:27 中大黑熊 阅读(2021) 评论(1) 推荐(0) 编辑
摘要: 原理应该不用多讲了,自己百度就可以。C++实现: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 10 //定义一些常变量 11 const int M = 26; //定义集合{a,b,...,z}的26个英文字母 12 13 //行和列均为5 14 const int ROW = 5; 15 const int COL = 5; 16 17 //定义5*5的加密矩阵 18 int K[RO... 阅读全文
posted @ 2013-10-14 09:30 中大黑熊 阅读(6235) 评论(0) 推荐(0) 编辑
摘要: 为了后面课程准备,先把基础的大数高精度运算先实现一遍。 1 为了后面课程准备,先把基础的大数高精度运算先实现一遍。 2 3 //BIGN.h 4 5 #ifndef BIGN_H 6 #define BIGN_H 7 8 #include 9 #include 10 #include 11 using namespace std; 12 const int MAXN = 3000; 13 14 //三元组gcd(a,b) = ax + by = d 15 struct gcd 16 { 17 int x; 18 int y; 19 int... 阅读全文
posted @ 2013-09-23 23:05 中大黑熊 阅读(419) 评论(0) 推荐(0) 编辑
摘要: 最近在学习python,后面遇到课本上的一个例子,是一个统计文本当中单词数的简单脚本,源代码如下:# !/usr/bin/python# -*- coding:utf-8 -*-#somescript.py#统计sys.stdin中单词数的简单脚本import systext = sys.stdin.read()words = text.split()wordcount = len(words)print 'Wordcount:',wordcount后面我回头觉得这个例子不太好,它只以空格来分割单词,但是面临这样的一种例子:Your mother was a hamster , 阅读全文
posted @ 2013-09-06 17:30 中大黑熊 阅读(752) 评论(1) 推荐(0) 编辑
摘要: 1166. Computer TransformatConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionA sequence consisting of one digit, the number 1 is initially written into a computer. At each successive time step, the computer simultaneously tranforms each digit 0 into the sequence 1 0 and each digit 1 into t 阅读全文
posted @ 2013-08-30 20:31 中大黑熊 阅读(607) 评论(0) 推荐(0) 编辑
摘要: 【Python】 sorted函数我们需要对List、Dict进行排序,Python提供了两个方法对给定的List L进行排序,方法1.用List的成员函数sort进行排序,在本地进行排序,不返回副本方法2.用built-in函数sorted进行排序(从2.4开始),返回副本,原始输入不变--------------------------------sorted--------------------------------------->>> help(sorted)Help on built-in function sorted in module __builtin_ 阅读全文
posted @ 2013-08-26 23:53 中大黑熊 阅读(178248) 评论(2) 推荐(6) 编辑
摘要: 1564. HOUSINGConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionFor the Youth Olympic Games in Singapore, the administration is considering to house each team in several units with at least 5 people per unit. A team can have from 5 to 100 members, depending on the sport they do. For exampl 阅读全文
posted @ 2013-08-25 11:12 中大黑熊 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 1049. MondriaanConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionSquares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One day, while working on his latest project, he was intrigued by the number of different ways in which he could order several objects to fill an arb 阅读全文
posted @ 2013-08-24 21:17 中大黑熊 阅读(313) 评论(0) 推荐(0) 编辑
摘要: 1090. HighwaysConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionThe island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem. They're planning to build some h 阅读全文
posted @ 2013-08-23 19:47 中大黑熊 阅读(1265) 评论(0) 推荐(0) 编辑
摘要: 1036. Crypto ColumnsConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionThe columnar encryption scheme scrambles the letters in a message (or plaintext) using a keyword as illustrated in the following example: Suppose BATBOY is the keyword and our message is MEET ME BY THE OLD OAK TREE. Sin 阅读全文
posted @ 2013-08-23 15:44 中大黑熊 阅读(534) 评论(0) 推荐(0) 编辑