hdoj 1098 Ignatius's puzzle
来源:互联网 发布:淘宝追加好评长心吗 编辑:程序博客网 时间:2024/06/11 18:22
Ignatius's puzzle
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7082 Accepted Submission(s): 4891
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
利用数学归纳法和多项式的知识:
假设x=1时成立,那么。。。
假设x=n时成立,那么有。。。
接下来只需证明x=n+1时成立即可,f(x+1)=5*( ... + ... + ... 每一项都有13 )+13*(...+ ...+ .. 每一项都有5)+ k*a*(x+1)
前面两项都能整除65,所以只需后一项能整除即可。
则有18+k*a 整除65。显而易见(18+k*a)%65==0 该式子65一循环,因此只需遍历1到65即可。
#include<stdio.h>void f(int k){ int a; for(a=1;a<=650;a++) { if((18+k*a)%65==0) { printf("%d\n",a); return ; } } printf("no\n");}int main(){ int i,j,k; while(scanf("%d",&k)!=EOF) { f(k); } return 0;}
0 0
- HDOJ 1098 Ignatius's puzzle
- HDOJ 1098 Ignatius's puzzle
- hdoj 1098 Ignatius's puzzle
- HDOJ 1098 Ignatius's puzzle
- hdoj-1098-Ignatius's puzzle
- HDOJ 1098 Ignatius's puzzle [数学归纳]
- HDOJ 1098 Ignatius's puzzle [数学归纳]
- hdoj 1098 Ignatius's puzzle(暴力)
- HDOJ 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
- Pangram
- 仿QQ打开“我”界面的滑动效果
- NGUI之UICamera
- C#拾遗之String类(一)
- Python基础06 循环
- hdoj 1098 Ignatius's puzzle
- 关于设置了LayoutAlgorithm.SINGLE_COLUMN后,某些手机的webview仍然无法适配图片的解决方案
- 在spring官网下载文档或jar包方法
- git 学习
- Uri详解之二——通过自定义Uri外部启动APP与Notification启动
- cocos2dx-2.x CCFileUtils文件管理类分析(2)
- 浅析Android binder机制
- websocket协议分析
- CentOS6.3编译安装git