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
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
0E100 E CnE C E CnE Cn C CnE n - n -
C
C E CnE nE - nE -
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()
{
//
}