摘要:1 import java.util.Scanner; 2 3 public class BinaryCode { 4 5 public String[] decode(String message){ 6 String[] original = new String[2]; 7 StringBuffer s1=new StringBuffer(); 8 StringBuffer s2=new StringBuffer(); 9 10 int flag1=0,flag2=0;11 ...
阅读全文
摘要:1 import java.util.Comparator; 2 3 public class PinYinComparator implements Comparator { 4 5 public int compare(Object o1, Object o2) { 6 try { 7 String s1=new String(o1.toString().getByte...
阅读全文
摘要:DescriptionA checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors, validating document contents, and in many other situations where it
阅读全文
摘要:DescriptionLittle Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in the nodes.This is an example of one of her creations: D ...
阅读全文
摘要:DescriptionIn 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the following conjecture: Every even number greater than 4 can be written as the sum of two odd prime numbers.For example: 8 = 3 + 5. Both 3 and 5 are odd prime numbers. 20 = 3 +
阅读全文
摘要:View Code #include <iostream>#include <cmath>#include <cstring>using namespace std;typedef struct move{ int from; int to;} move;int main(){ move m[400]; int shap[400]; int T, N; int x, y, res; cin>>T; while(T--) { memset(shap,0,sizeof(shap)); cin>>N; f...
阅读全文
摘要:DescriptionSome positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given positive integer have? For example, the integer 53 has two representations 5 + 7 + 11 + 13 + 17 and 53. The integer 41 has three representations 2+3+5+7+
阅读全文
摘要:来源:http://hi.baidu.com/hking1987/blog/item/3c9525f50db21d66ddc4749b.html素数还有很多东西需要学,先整理三种最简单的判断素数的方法,以后再深究补充。判断n是否为素数1、最简单的方法用n除以2-sqrt(n),有一个能除尽就不是素数,否则是素数。时间复杂度:O(sqrt(n))2、素数判断法:这种方法是对上面方法的改进,上面方法是对2-sqrt(n)之间的数进行判断是否能除尽,而因为有如下算术基本定理,可以减少判断量。算术基本定理:又称为素数的唯一分解定理,即:每个大于1的自然数均可写为素数的积,而且这些素因子按大小排列之后,
阅读全文