hdu1098:Ignatius's puzzle

来源:互联网 发布:java旅游管理项目描述 编辑:程序博客网 时间:2024/05/16 15:10
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
111009999
 

Sample Output
22no43
 


题意就是给定k的值,求出最小的a,是的x为任何整数值时,方程的值总是能整除65

这是一道数学题

用数学归纳法

设f(x)能整除65

要证明f(x+1)能整除65的话就只需要证明f(x+1)-f(x)能整除65

用二项式分拆

因为常数是13的总能提出一个5的系数相乘,5的则能提出13相乘

所以前面的项必能被65整除,现在只许看后面的a*k了

所以最后只需证明18+a*k能否被65整除就行了

推出了这个就简单了

 

#include <stdio.h>int main(){    int k,a;    while(~scanf("%d",&k))    {        for(a = 1;a<=65;a++)        {            if((18+a*k)%65 == 0)            {                printf("%d\n",a);                break;            }        }        if(a>65)        printf("no\n");    }    return 0;}


 

原创粉丝点击