HDU 1098 Ignatius's puzzle(数论-其它)
来源:互联网 发布:淘宝个人空间在哪里 编辑:程序博客网 时间:2024/05/22 13:35
Ignatius's puzzle
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".
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
Author
eddy
Recommend
We have carefully selected several similar problems for you: 1071 1014 1052 1097 1082
题目大意:
解题思路:给定一个k,找到最小的a 使得 f(x)=5*x^13+13*x^5+k*a*x ,f(x)%65永远等于0
因为 f(x+1)=5*(x+1)^13+13*(x+1)^5+k*a*x,所以 f(x+1)=f (x) + 5*( (13 1 ) x^12 ...... .....+(13 13) x^0 )+ 13*( (5 1 )x^4+...........+ ( 5 5 )x^0 )+k*a除了5*(13 13) x^0 、13*( 5 5 )x^0 和k*a三项以外,其余各项都能被65整除.那么也只要求出18+k*a能被65整除就可以了。
18+k*a=65*bax+by = c的方程有解的一个充要条件是:c%gcd(a, b) == 0
解题代码:“
#include <iostream>#include <cstdio>using namespace std;int gcd(int a,int b){ return b>0?gcd(b,a%b):a;}int main(){ int k; while(scanf("%d",&k)!=EOF){ if(18%gcd(k,65)==0){ for(int a=0;;a++){ if( (18+k*a)%65==0 ){ printf("%d\n",a); break; } } } else printf("no\n"); } return 0;}
2 0
- HDU 1098 Ignatius's puzzle(数论-其它)
- HDU 1098 Ignatius's puzzle(数论)
- hdu 1098 Ignatius's puzzle数论
- HDU - 1098 - Ignatius's puzzle (数论 - 费马小定理)
- Ignatius's puzzle(数论)
- hdu 1098Ignatius's puzzle(math)
- hdu 1098 Ignatius's puzzle
- hdu 1098 Ignatius's puzzle
- HDU 1098 Ignatius's puzzle
- HDU 1098 Ignatius's puzzle
- Hdu 1098 - Ignatius's puzzle
- hdu 1098 Ignatius's puzzle
- hdu 1098 Ignatius's puzzle
- HDU 1098 Ignatius's puzzle
- hdu-1098 Ignatius's puzzle
- hdu 1098 Ignatius's puzzle
- HDU 1098 Ignatius's puzzle
- HDU 1098 Ignatius's puzzle
- MongoDB权限配置
- TestNG监听器实现用例运行失败自动截图、重运行功能
- 俞敏洪|马云|牛根|史玉柱|经典语录大全
- CXF实现webService服务(一)
- Android应用开发相关版本下载资源
- HDU 1098 Ignatius's puzzle(数论-其它)
- C++重载与重写
- DOM Event delegation
- hdu 2045 不容易系列之(3)—— LELE的RPG难题
- oc的switch中使用alloc,new语法报错解决方法
- SQL Server孤立用戶
- PM如何写好产品需求文档
- 10010 - Where's Waldorf?(找出单词的位置,可以在八个直线方向)
- 用netbeans和xdebug调试php的配置