Always an integer
Combinatorics is a branch of mathematics chiefly concerned
with counting discrete objects. For instance, how many ways can you
pick two people out of a crowd
of

Many questions like these
have answers that can be reduced to simple polynomials
in
2
-
4 - 6n
3 + 23n
2 - 18n
3 + 3n
2
+
These polynomials are answers to questions that can have integer answers only. But since they have fractional coefficients, they look as if they could produce non-integer results! Of course, evaluating these particular polynomials on a positive integer always results in an integer. For other polynomials of similar form, this is not necessarily true. It can be hard to tell the two cases apart. So that, naturally, is your task.
Input
The input consists of
multiple test cases, each on a separate line. Each test case is an
expression in the
form
E
-
E
0
E
100 E Cn
E C E Cn
E Cn C Cn
E n - n -
C
C E Cn
E n
E - n
E -
Only non-negative
C -
Exponents in consecutive terms are strictly decreasing.
-
C
D
See the sample input for details.
Input is terminated by a line containing a single period.
Output
For each
test case, print the case number (starting with 1). Then print
`Always an
integer' if the test case polynomial evaluates to an
integer for every positive
integer
Sample
Input
(n^2-n)/2
(2n^3+3n^2+n)/6
(-n^14-11n+1)/3
.
Sample
Output
Case 1: Always an integer
Case 2: Always an integer
Case 3: Not always an integer
题意: 判断多项式是否恒为整数.
解题思路:
代码:
#include
#include
#include
using namespace std;
#define MAX 3100
typedef long long ll;
struct node
{
}a[110];
char str[MAX];
char ch[15];
int D;
inline int max(int a, int b)
{
}
ll getValue(int num, int value, int D)
{
}
bool judge(int value, int D, int num)
{
}
int main()
{
//
}
探讨组合数学中关于计数离散对象的问题,通过多项式形式表达问题解答,并判断这些表达式是否总是能产生整数值。
373

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



