POJ2154 Color】的更多相关文章

由于这是第一天去实现polya题,所以由易到难,先来个铺垫题(假设读者是看过课件的,不然可能会对有些“显然”的地方会看不懂): 一:POJ1286 Necklace of Beads :有三种颜色,问可以翻转,可以旋转的染色方案数,n<24. 1,n比较小,恶意的揣测出题人很有可能出超级多组数据,所以先打表. 2,考虑旋转: ;i<n;i++) sum+=pow(n,gcd(n,i)); 3,考虑翻转: ) sum+=n*pow(,n/+) ; else { sum+=n/*pow(,n/)…
你随便写一下出来,发现polya原理的式子里面好多gcd是相同的,gcd(n,i)=k可以改写成gcd(n/k,i/k)=1,也就是说指数为k的项的个数为phi(n/k),就很好求了,最后除的那个n直接放到指数上即可,没必要用逆元. import java.util.*; import java.io.*; public class Main { public static int phi(int n){ int ans=n; for(int i=2;i*i<=n;++i){ if(n%i==0…
Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10322   Accepted: 3360 Description Beads of N colors are connected together into a circular necklace of N beads (N<=1000000000). Your job is to calculate how many different kinds of the nec…
Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11654   Accepted: 3756 Description Beads of N colors are connected together into a circular necklace of N beads (N<=1000000000). Your job is to calculate how many different kinds of the nec…
题目 Beads of N colors are connected together into a circular necklace of N beads (N<=1000000000). Your job is to calculate how many different kinds of the necklace can be produced. You should know that the necklace might not use up all the N colors, a…
题目:http://poj.org/problem?id=2154 今天学了个高端的东西,Polya定理... 此题就是模板,然而还是写了好久好久... 具体看这个博客吧:https://blog.csdn.net/wsniyufang/article/details/6671122 代码如下: #include<iostream> #include<cstdio> #include<cstring> using namespace std; ; int X,n,p,p…
参考链接: http://www.cnblogs.com/hankers/archive/2012/08/03/2622231.html http://blog.csdn.net/raalghul/article/details/51767941 首先来说说burnside引理是什么. 一天你正在刷题,看到一道关于染色的问题,你认为是一个傻逼题,然后认真一看题目上面写着旋转.翻转后相同的计算一次......你立刻就傻眼了. 接下来是科普时间. 首先我们考虑什么东西叫置换,例如(1,2,3,4,5…
定义简化版: 置换,就是一个1~n的排列,是一个1~n排列对1~n的映射 置换群,所有的置换的集合. 经常会遇到求本质不同的构造,如旋转不同构,翻转交换不同构等. 不动点:一个置换中,置换后和置换前没有区别的排列 Burnside引理:本质不同的方案数=每个置换下不动点的个数÷置换总数(一个平均值) Polya定理:一个置换下不动点的个数=颜色^环个数.(辅助Burnside引理,防止枚举不动点复杂度过高) 这篇文章写得很详细了(具体的在此不说了): Burnside引理与Polya定理 **特…
Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 661    Accepted Submission(s): 363 Problem Description On birthday, Anthony got a toy. It is constructed with N+1(N>=3) balls and 2*N sticks. All…
Description 有一个长度为N的环,上面写着'X'和'E',问本质不同的环有多少种.(N不超过200000). Input The input file contains a single integer 1 <= n <= 200000. Output Output a single integer --- the number circular strings of length n. Sample Input 3 Sample Output 4 polya裸题,和[POJ2154…
[POJ2154]Color 题意:求用$n$种颜色染$n$个珠子的项链的方案数.在旋转后相同的方案算作一种.答案对$P$取模. 询问次数$\le 3500$,$n\le 10^9,P\le 30000$ 题解:旋转i次的循环个数显然是$gcd(i,n)$,然后套用Pólya定理. $$ans=\frac 1 n \sum\limits_{i=1}^nn^{gcd(i,n)}$$ $$ans=\sum\limits_{i=1}^nn^{gcd(i,n)-1}$$ $$ans=\sum\limit…
http://poj.org/problem?id=2154 (题目链接) 题意 n个珠子的项链,可以染上n中颜色,项链可以旋转不能翻转,求染色方案数. Solution 经典的公式: \begin{aligned} ans &= \sum_{i=0}^{n-1} gcd(n,i)\\ &= \sum_{d|n} (n^{d-1}*φ(\frac{n}{d})) \end{aligned} 于是就可以求了,然而时限卡太死,只能用int,还必须枚举质数求phi.. 代码 // poj2154…
题目描述 $T$ 组询问,用 $n$ 种颜色去染 $n$ 个点的环,旋转后相同视为同构.求不同构的环的个数模 $p$ 的结果. $T\le 3500,n\le 10^9,p\le 30000$ . 题解 Polya定理+欧拉函数 根据 poj2409 中得到的结论,答案为: $\frac{\sum\limits_{i=1}^nn^{\gcd(i,n)}}n=\sum\limits_{i=1}^nn^{\gcd(i,n)-1}$ 由于 $n$ 有 $10^9$ 之大,因此考虑优化这个式子. 枚举…
转自:http://www.cnblogs.com/wj-love/archive/2012/09/14/2685281.html 1,将#3C3C3C 赋给background this.selectBook.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3C3C3C")); 2,colordialog中的值(ARGB)转换为Brush Brush br = new SolidCo…
图片中存在着色版的概念,二维矩阵的每个元素的值指定了一种颜色,因此可以显示出彩色. 迁移调色板 下述python代码将VOC数据集中的某个语义分割的图片的调色板直接应用在一个二维矩阵代表的图像上 #label_im is a numpy array of 1 x height x width #return an Image object,call its' save('out.png') functioin to save as image file def palette( label_im…
经常使用System.Drawing.Color, 本篇介绍一下颜色与名称及RGB值的对应关系. 1. 颜色与名称的对照表(点击下图放大看): 2. 颜色与RGB值对照表: Color.AliceBlue 240,248,255 Color.LightSalmon 255,160,122 Color.AntiqueWhite 250,235,215 Color.LightSeaGreen 32,178,170 Color.Aqua 0,255,255 Color.LightSkyBlue 135…
Color Basic 看见色彩三要素: 光源,物体,视觉 加色色彩模型:R,G,B 多用于显示器 减色色彩模型:C,M,Y,K 多用于打印复印 Paper 东亚地区常用A系列标准用纸,在多功能一体机上一般能从A3支持到A6.他们的尺寸关系是从A0开始折半递减. 美国常用Letter,所以在装英语驱动时候,注意把入纸的默认纸张尺寸改为A4. 用纸根据薄厚不同,分为很多种纸,常用普通纸有70,75,80gsm(g/m^2). 还有厚纸(106~176gsm), 信笺纸(常用于银行单据),特殊的投影…
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="abc_search_url_text_normal">#ff7fa87f</color> <item type="color" name="abc_search_url_text_selected">@*android:…
在 IOS 中,对 UIScrollView 的滚动条(ScrollBar Indicators)的自定义设置接口,一直都是很少的.除了能自定义简单的样式(UIScrollViewIndicatorStyle)和是否启用外,对于 一直显示滚动条.自定义滚动条(ScrollBar Indicators)的Width .颜色等,都是不能很方便的设置的. 虽然不能很方便,但是还是能实现的.通过一天的努力,不断的 google 和 overflow,终于找到了几个比较完美的解决办法. 本文禁止任何网站转…
OpenCASCADE Color Scale eryar@163.com Abstract. The color scale is a specialized label object that displays a color map and an accompanying numerical scale for color mapped or contour data plots. As the geometry modeling kernel of SALOME, OpenCASCADE…
上计算机视觉课老师布置的作业实现论文:Color Transfer between Images 基本思路是: 1.给定srcImg和targetImg 2.将RGB空间转为Lab空间 3.根据论文中公式: 计算每一个像素点 4.将resultImg转回到RGB空间显示 效果图:       见代码: #include <opencv2/opencv.hpp> #include <opencv2/core/core.hpp> #include <opencv2/imgproc…
这道题目很简单,考察的就是结构体数组的应用,直接贴代码了 #include <stdio.h> #include <math.h> typedef struct color { int r; int g; int b; }color; double distance(color c1,color c2) { return sqrt(pow((c1.b-c2.b),2)+pow((c1.g-c2.g),2)+pow((c1.r-c2.r),2)); } int equal(color…
UVA - 1625 Color Length   白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束   和模拟赛那道环形DP很想,计算这次转移会给其他的元素带来的代价,也就是转移前已经出现但还没结束的元素都会代价+1   预处理每种颜色在两个序列中出现的位置bg[i][0/1]和ed[i][0/1], 计算f[i][j]时同时计算w[i][j]为(i,j)这个状态已经出现还没结束的个数 注意bg要先初始化为INF,计算w: if(b…
You can change the file color to whatever you want. File > Settings > Editor > Colors&Fonts > File Status > (Unkown > foreground). The files in Pycharm are under Version Control. Pycharm changes the file's color by the status of file…
在给Background赋值时,除了自带的Red,Blue,Black等,可以通过以下方法赋予其他颜色. 主要是将Hex转换成ARGB(A:alpha,表示透明度.R:Red.G:Green.B:Blue),其中ARGB取值均在0--255之间 该方法传入的字符串参数可以类似 #21459A 或者 #FF21459A public static Color? GetColorFromHex(String colorStr) //? 表示返回值可以为null { if (colorStr != n…
// Get the instance of the UITextField of the search bar UITextField *searchField = [searchBar valueForKey:@"_searchField"]; // Change search bar text color searchField.textColor = [UIColor redColor]; // Change the search bar placeholder text co…
最基本的api 是对比色,对与我这种菜鸟来说,没有什么比在一个背景色下 用什么颜色的文字坑蛋疼的事情了,这个工具可以帮助大家很好解决这个问题 api 地址 http://compass-style.org/reference/compass/utilities/color/contrast/ 要是真的能实现任何一个背景色 都可以选出来一个对比色 那就好了, 不过compass 并没有实现这个功能,而是先定义了一个淡色和深色,然后根据你传入的颜色判断,是给你返回深色好呢,还是返回淡色好呢 ,这个a…
写控件的时候经常会遇到颜色选择问题,下面贴出常用颜色表示,方便选择. <?xml version="1.0" encoding="utf-8"?><resources>    <color name="colorPrimary">#3F51B5</color>    <color name="colorPrimaryDark">#303F9F</color>…
16个基本颜色关键字 Basic color keywords Color Color Name HEX RGB   black #000000 0,0,0   silver #C0C0C0 192,192,192   gray #808080 128,128,128   white #FFFFFF 255,255,255   maroon #800000 128,0,0   red #FF0000 255,0,0   purple #800080 128,0,128   fuchsia #FF…
本例演示了如何从相机preview缓冲区获取YCbCr模块,并且转化为ARGB. 1. 什么是YCbCr y:像素的亮度.以范围从 0 到 255 的字节值形式返回(亮度值始终为正值). cr:像素的红色色差(色差).以有符号值的形式返回,范围从 -128 到 127 的整数值. cb:像素的蓝色色差(色差).以有符号值的形式返回,范围从 -128 到 127 的整数值. 常见的3 个基本色彩模型是RGB,CMYK和YUV. YCbCr是YUV压缩和偏移的版本,但是Cb,Cr 同样都指色彩,只是…