Permutation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 910 Accepted Submission(s): 536
Problem Description
There is an arrangement of N numbers and a permutation relation that alter one arrangement into another.
For example, when N equals to 6 the arrangement is 123456 at first. The replacement relation is 312546 (indicate 1->2, 2->3, 3->1, 4->5, 5->4, 6->6, the relation is also an arrangement distinctly).
After the first permutation, the arrangement will be 312546. And then it will be 231456.
In this permutation relation (312546), the arrangement will be altered into the order 312546, 231456, 123546, 312456, 231546 and it will always go back to the beginning, so the length of the loop section of this permutation relation equals to 6.
Your task is to calculate how many kinds of the length of this loop section in any permutation relations.
For example, when N equals to 6 the arrangement is 123456 at first. The replacement relation is 312546 (indicate 1->2, 2->3, 3->1, 4->5, 5->4, 6->6, the relation is also an arrangement distinctly).
After the first permutation, the arrangement will be 312546. And then it will be 231456.
In this permutation relation (312546), the arrangement will be altered into the order 312546, 231456, 123546, 312456, 231546 and it will always go back to the beginning, so the length of the loop section of this permutation relation equals to 6.
Your task is to calculate how many kinds of the length of this loop section in any permutation relations.
Input
Input contains multiple test cases. In each test cases the input only contains one integer indicates N. For all test cases, N<=1000.
Output
For each test case, output only one integer indicates the amount the length of the loop section in any permutation relations.
Sample Input
1 2 3 10
Sample Output
1 2 3 16
Author
HIT
Source
Recommend
zhuyuanchen520
对于一个置换群,循环节的长度为独立置换环长度的最小公倍数。
这个问题问的是循环节的长度有多少种。
可以转化成和为N的数的最小公倍数有多少种。
因为1对最小公倍数没有影响,所以可以转化成和小于等于N的最小公倍数有多少种。
// test.cpp : 定义控制台应用程序的入口点。
//
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int MAXN = 1000 + 10;
const long long INF = 1000000000000000;
typedef long long ll;
int vis[MAXN] = { 0 };
int p[MAXN];
ll dp[MAXN], ans[MAXN];
int n;
int tot = 0;
void getprime() {
for (int i = 2; i < MAXN; i++) {
if (!vis[i]) {
p[tot++] = i;
for (int j = i * 2; j < MAXN; j += i) {
vis[j] = 1;
}
}
}
}
void init() {
getprime();
dp[0] = 1;
for (int i = 0; i < tot; i++) {
for (int j = MAXN-1; j ; j--) {
for (int k = p[i]; k <= j; k *= p[i]) {
dp[j] += dp[j - k];
}
}
}
ans[0] = 1;
for (int i = 1; i <= 1000; i++)
ans[i] = ans[i - 1] + dp[i];
}
int main() {
init();
while (cin >> n)
cout << ans[n] << endl;
}

本文探讨了在一个置换群中,不同置换关系下循环节长度的种类数量计算问题。通过数学转换,将问题转化为求解特定条件下最小公倍数的不同组合。
1203

被折叠的 条评论
为什么被折叠?



