首页 > ACM题库 > HDU-杭电 > HDU 1098 Ignatius’s puzzle[解题报告] java
2013
11-27

HDU 1098 Ignatius’s puzzle[解题报告] java

Ignatius’s puzzle

问题描述 :

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".

输入:

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

输出:

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.

样例输入:

11
100
9999

样例输出:

22
no
43

Ignatius’s puzzle

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		while(input.hasNext()){
			int k=input.nextInt();
			int i=0;
			for(i=1;i<65;i++){
				if((18+k*i)%65==0){
					System.out.println(i);
					break;
				}
			}
			if(i>=65)
				System.out.println("no");
		}
	}
}

 


  1. [email protected]

  2. [email protected]