POJ 2409
来源:互联网 发布:mac 之间airdrop怎么用 编辑:程序博客网 时间:2024/06/06 04:47
裸的polya定理
#include <iostream>
#include <string.h>#include <stdio.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
int gcd( int a, int b)
{
if(b == 0)
return a;
return gcd(b, a%b);
}
int n, m;
int main()
{
double ans = 0;
while(scanf("%d %d",&m, &n) != EOF && (n + m))
{
ans = 0;
if(n == 0)
{
printf("0\n");
continue;
}
if(n%2)
ans += n* pow(m*1.0, (n+1.0)/2.0);
else
{
ans += n/2 * pow(m*1.0, (n+2.0)/2.0);
ans += n/2 * pow(m*1.0, n/2.0);
}
for( int i = 1; i <= n ; i++)
{
int res = gcd(n, i);
ans += pow(m*1.0, res);
}
ans = ans/(2*n);
printf("%d\n",(int)ans);
}
return 0;
}
0 0
- poj 2409
- POJ 2409
- POJ 2409
- poj 2409 poj 1286【马克】
- POJ 1286 && POJ 2409 Polya定理
- poj 2409解题报告
- POJ 2409 波利亚原理
- POJ 2409 Polya定理
- poj 2409 polya定理
- poj 2409 简单polya
- poj 2409 polya定理
- poj 2409 Polya
- POJ 2409 let_it_bead
- poj 2409 polya定理
- poj 2409 polya计数
- POJ 2409 ploya定理
- POJ 2409 Polya组合
- poj 2409 polya原理
- 8张图理解Java
- 快来看高科技微信产品
- Android控件:textView
- Android JNI知识总结
- Windows共享文件夹的权限设定
- POJ 2409
- C++实现视频流转换为图片
- Permutations -- leetcode
- Java 8简明教程
- iOS UIImage的剪裁、合并实现
- 彻底搞懂C语言指针
- CODEVS 1204 寻找子串位置
- 溱湖拓展训练基地-绿岛度假村拓展培训中心-溱湖湿地公园拓展培训
- 让文本输入框充满屏幕的的宽度