poj2409
来源:互联网 发布:淘宝优选好店有假货吗 编辑:程序博客网 时间:2024/06/04 19:57
【题意】
用c种颜色染正s边形s个顶点有多少种不同的方案
【输入】
每行一个c、s
以两个0结束
【输出】
对于每组数据输出一个数表示有多少种不同的方案
polya定理经典模板
program poj2409;var c,s,i,j,k:longint; ans:int64;function gcd (a,b:int64):int64;var i:longint;begin while a mod b<>0 do begin i:=a mod b; a:=b; b:=i; end; exit(b);end;function quick (a,b:int64):int64;var i:int64;begin if b=0 then exit(1); if b=1 then exit(a); i:=quick(a,b div 2); if b and 1 = 1 then exit(i*i*a) else exit(i*i);end;begin repeat read(c,s); if (c=0)and(s=0) then break; if (c=0)or(s=0) then begin writeln(0); continue; end; if s and 1 = 1 then ans:=s*quick(c,s div 2 + 1) else ans:=(s div 2)*(quick(c,s div 2)+quick(c,s div 2 +1)); for i:=1 to s do ans:=ans+quick(c,gcd(s,i)); ans:=ans div (2*s); writeln(ans); until false;end.
- poj2409
- poj2409
- poj2409
- POJ2409 染色问题
- poj2409 Let it Bead
- polya定理 poj1286 poj2409
- poj2409 Let it Bead
- Poj2409 polya计数
- POJ2409 Let it Bead
- polya定理 和 置换 poj2409
- POJ2409--Let it Bead--Polya
- poj2409 Let it Bead(置换)
- Polya计数法总结 POJ2409&&2154&&SGU282
- poj2409(polya计数 套模版)
- poj2409 等价类计数问题 polya定理
- poj2409 Let it Bead polya定理
- polya定理 poj2409 Let it Bead
- POJ2409 Let it Bead【Polya定理】
- 用Spring管理Hibernate连接多个数据源配置文件
- poj 3427 模拟
- 开源权限系统sshpermissions
- SQL语句大全
- Eclipse 自动提示(auto complete)强化
- poj2409
- Total Return Swap
- 将自己积累的一些重构经验写成半本书
- hadoop-扫盲篇
- 我在Facebook学到的10个经验
- Common.MessageBox
- LaTeX使用框架
- Linux扩展SWAP分区
- 日本漫游