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,是否存在一个数a,对任意x都能使得f(x)能被65整除。

现假设存在这个数a ,因为对于任意x方程都成立

所以,当x=1时f(x)=18+ka

又因为f(x)能被65整出,故设n为整数

可得,f(x)=n*65;

即:18+ka=n*65;

因为n为整数,若要方程成立

则问题转化为,

对于给定范围的a只需要验证,

是否存在一个a使得(18+k*a)%65==0

所以容易解得

注意,这里有童鞋不理解为什么a只需到65即可

因为,当a==66时

也就相当于已经找了一个周期了,所以再找下去也找不到适当的a了

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int k= sc.nextInt();
boolean flag=false;
for(int a=0;a<=65;a++){
if((18+k*a)%65==0){
System.out.println(a);
flag = true;
break;
}
} if(!flag){
System.out.println("no");
} } } }

HDOJ 1098 Ignatius's puzzle的更多相关文章

  1. 数学--数论--HDU 1098 Ignatius's puzzle (费马小定理+打表)

    Ignatius's puzzle Problem Description Ignatius is poor at math,he falls across a puzzle problem,so h ...

  2. 【HDOJ】1098 Ignatius's puzzle

    数学归纳法,得证只需求得使18+ka被64整除的a.且a不超过65. #include <stdio.h> int main() { int i, j, k; while (scanf(& ...

  3. HDU 1098 Ignatius's puzzle(数学归纳)

    以下引用自http://acm.hdu.edu.cn/discuss/problem/post/reply.php?postid=8466&messageid=2&deep=1 题意以 ...

  4. HDU 1098 Ignatius's puzzle

    http://acm.hdu.edu.cn/showproblem.php?pid=1098 题意 :输入一个K,让你找一个a,使得f(x)=5*x^13+13*x^5+k*a*x这个f(x)%65等 ...

  5. HDU - 1098 - Ignatius's puzzle - ax+by=c

    http://acm.hdu.edu.cn/showproblem.php?pid=1098 其实一开始猜测只要验证x=1的时候就行了,但是不知道怎么证明. 题解表示用数学归纳法,假设f(x)成立,证 ...

  6. 题解报告:hdu 1098 Ignatius's puzzle

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1098 题目中文是这样的: 伊格内修斯在数学上很差,他遇到了一个难题,所以他别无选择,只能上诉埃迪. 这 ...

  7. HDU 1098 Ignatius's puzzle 费马小定理+扩展欧几里德算法

    题目大意: 给定k,找到一个满足的a使任意的x都满足 f(x)=5*x^13+13*x^5+k*a*x 被65整除 推证: f(x) = (5*x^12 + 13 * x^4 + ak) * x 因为 ...

  8. 数学: HDU1098 Ignatius's puzzle

    Ignatius's puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  9. Ignatius's puzzle

    Ignatius's puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

随机推荐

  1. Python自动化之5种session类型

    Django中默认支持Session,其内部提供了5种类型的Session供开发者使用: 数据库(默认) 缓存 文件 缓存+数据库 加密cookie 1.数据库Session Django默认支持Se ...

  2. 招行ODC项目表彰

  3. 织梦(dedecms)如何清空全部文章和删除后新增文章id号归1的方法

    很多朋友在使用织梦程序做网站的过程中,难免需要添加一些测试文章用于测试网站功能模板等,还有些人朋友网站改版需要变更内容的时候,面对着众多的老文章后总是一筹莫展! 由于织梦后台并不自带一键删除整站文章的 ...

  4. (转)织梦DedeCMSv5.7安装体验数据包的方法

    1.先安装一个全新的DedeCMS v5.7 GBK系统,这里以DedeCMS v5.7 GBK系统为例. 2.下载数据体验包: 如果是gbk则下载:http://www.dedecms.com/de ...

  5. Webview的使用和注意事项

    1.webView是一个展示web网页的控件,继承 AbsoluteLayout 2.webview的俩个回调应用层: 1)webViewClient 这个对象的创建 WebViewClient my ...

  6. 统计机器翻译(SMT)步骤总结

    本文是在Niutrans论坛中的系列教程中总结出来的. 1.语料预处理 预处理的结果是生成双语分词之后的文件,该步需要注意的是对规则短语,比如数字.日期.网址等,进行泛化处理.可以用正则方法或者其它方 ...

  7. MVC之序列化

    1.AdminUserInfo.cs [Serializable]序列化类——System.SerializableAttribute 串行化是指存储和获取磁盘文件.内存或其他地方中的对象.在串行化时 ...

  8. 在fragment中获取他附着的activity中的变量

    final String data=(关联的activity类)getActivity().getData(); getData();自定义的方法

  9. Extjs之rowEditing编辑状态时列不对齐

    Extjs在使用rowEditing的时候,会在每一列加上editor属性,表示当处于编辑状态时这一列的值是什么类型的,后突然发现在rowEditing处于编辑状态时每一列的宽度边框了,如果列数非常多 ...

  10. [HttpClient]HttpClient简介

    1. 前言 HTTP 协议可能是现在 Internet 上使用得最多.最重要的协议了,越来越多的 Java应用程序需要直接通过 HTTP 协议来访问网路资源.虽然在 JDK 的 java net包中已 ...