hdu1098Ignatius's puzzle泰勒展开/二项式展开

Ignatius's puzzle

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9049    Accepted Submission(s): 6288


Problem Description
Ignatius is poor at math,he falls across a puzzle problem,so he has no choice but to appeal to Eddy. this problem describes that:f(x)=5*x^13+13*x^5+k*a*x,input a nonegative integer k(k<10000),to find the minimal nonegative integer a,make the arbitrary integer x ,65|f(x)if
no exists that a,then print "no".

 

Input
The input contains several test cases. Each test case consists of a nonegative integer k, More details in the Sample Input.
 

Output
The output contains a string "no",if you can't find a,or you should output a line contains the a.More details in the Sample Output.
 

Sample Input
  
  
11 100 9999
 

Sample Output
  
  
22 no 43
题意:就是f(x)=5*x^13+13*x^5+k*a*x,输入一个k,让你求使得f(x)%65==0的a的最小值是多少。
完全的数学题,刚开始也是一头雾水。。。仔细想想
用数学归纳法,因为对于任意x都要成立,所以f(x+1)和f(x)成立,对于f(x+1),展开得到
f(x+1)=5*(C(13,0)*x^13+C(13,1)*x^12+...C(13,13)*x^0)+13*(C(5,0)*x^5+C(5,1)*x^4+...+C(5,5)*x^0)+k*a*(x+1)
f(x+1)=5*x^13+13*x^5+k*a*x+5*(C(13,1)*x^12+...C(13,13)*x^0)+13*(C(5,1)*x^4+...+C(5,5)*x^0)+k*a
而f(x)=5*x^13+13*x^5+k*a*x
即f(x+1)=f(x)+5*(C(13,1)*x^12+...C(13,13)*x^0)+13*(C(5,1)*x^4+...+C(5,5)*x^0)+k*a
f(x+1)=f(x)+5*(C(13,1)*x^12+...C(13,12)*x^1)+13*(C(5,1)*x^4+...+C(5,4)*x^1)+k*a+18
可以发现f(x+1)中,f(x)是能被65整除的,5*(C(13,1)*x^12+...C(13,12)*x^1)+13*(C(5,1)*x^4+...+C(5,4)*x^1)这一长段也是能够被65整除的,这是因为其中都含有5*13因子,所以问题就化成了k*a+18能否被65整除了。
求其最小值,考虑(k*a+18)%65=(k*a%65+18%65)%65,所以只需将a从1到65遍历,即可判断能否被65整除,同时找出最小值。
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#define eps 1e-8
#define zero(x) (((x>0?(x):-(x))-eps)
#define mem(a,b) memset(a,b,sizeof(a))
#define memmax(a) memset(a,0x3f,sizeof(a))
#define pfn printf("\n")
#define ll __int64
#define ull unsigned long long
#define sf(a) scanf("%d",&a)
#define sf64(a) scanf("%I64d",&a)
#define sf264(a,b) scanf("%I64d%I64d",&a,&b)
#define sf364(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)
#define sf2(a,b) scanf("%d%d",&a,&b)
#define sf3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sf4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define sff(a) scanf("%f",&a)
#define sfs(a) scanf("%s",a)
#define sfs2(a,b) scanf("%s%s",a,b)
#define sfs3(a,b,c) scanf("%s%s%s",a,b,c)
#define sfd(a) scanf("%lf",&a)
#define sfd2(a,b) scanf("%lf%lf",&a,&b)
#define sfd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define sfd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)
#define sfc(a) scanf("%c",&a)
#define ull unsigned long long
#define debug printf("***\n")
const double PI = acos(-1.0);
const double e = exp(1.0);
const int INF = 0x7fffffff;;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> inline T Min(T a, T b) { return a < b ? a : b; }
template<class T> inline T Max(T a, T b) { return a > b ? a : b; }
bool cmpbig(int a, int b){ return a>b; }
bool cmpsmall(int a, int b){ return a<b; }
using namespace std;
int main()
{
   // freopen("data.in","r",stdin);
    int k;
    while(~sf(k))
    {
        int cnt,i;
        for(i=1;i<=65;i++)
        {
            cnt=18+i*k;
            if(cnt%65==0)
                break;
        }
        if(i==66)
            printf("no\n");
        else
            printf("%d\n",i);
    }
    return 0;
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值