Polya定理是个很神奇的东西~
题目大意:
n个珠子串成一个圆,用三种颜色去涂色。问一共有多少种不同的涂色方法。
不同的涂色方法被定义为:如果这种涂色情况翻转,旋转不与其他情况相同就为不同。
解题思路:
Polya定理模版题。
对于顺时针长度为i的旋转,为pow(3,__gcd(n,i);
对于翻转,当为奇数时,有:n*pow(3.0,n/2+1);
当为...
分类:
其他好文 时间:
2014-07-26 02:31:26
阅读次数:
201
这个题和POJ 1286 是一个题,只不过那是一个颜色数量固定的题而这个不固定。
这是链接:POJ 1286 Necklace
of Beads
下面是代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#d...
分类:
其他好文 时间:
2014-07-26 02:30:16
阅读次数:
198
Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The...
分类:
其他好文 时间:
2014-07-26 01:37:06
阅读次数:
221
Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially...
分类:
其他好文 时间:
2014-07-26 00:37:46
阅读次数:
237
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega...
分类:
其他好文 时间:
2014-07-26 00:23:26
阅读次数:
242
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.2...
分类:
其他好文 时间:
2014-07-26 00:05:16
阅读次数:
301
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be on...
分类:
其他好文 时间:
2014-07-25 14:18:51
阅读次数:
284
Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ...
分类:
其他好文 时间:
2014-07-25 14:13:21
阅读次数:
317
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.题解,很巧妙的一道题,对于一个0-1矩阵,它的每一行及以上都可以看...
分类:
其他好文 时间:
2014-07-25 10:53:01
阅读次数:
292
You are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenati...
分类:
其他好文 时间:
2014-07-25 02:31:14
阅读次数:
210