HDU1098 Ignatius's puzzle【数学+暴力】

Ignatius's puzzle

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 11558    Accepted Submission(s): 8116


 

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.

扫描二维码关注公众号,回复: 2643055 查看本文章

 

Sample Input

 

11 100 9999

 

Sample Output

 

22 no 43

问题链接HDU1098 Ignatius's puzzle

问题描述:(略)

问题分析

  对于给定的公式,假设x=1,那么f(x)=18+ka,而65|f(x)即f(x)能够被65整除。那么,枚举一下a就可以了,a<=65。

程序说明:(略)

参考链接:(略)

题记:(略)

AC的C++语言程序如下:

/* HDU1098 Ignatius's puzzle */

#include <iostream>

using namespace std;

const int MOD = 65;

int main()
{
    int k, i;
    while(scanf("%d", &k) != EOF) {
        for(i = 1; i <= MOD; i++)
            if((18 + i * k) % MOD == 0) {
                printf("%d\n", i);
                break;
            }
        if(i > MOD)
            printf("no\n");
    }

    return 0;
}

猜你喜欢

转载自blog.csdn.net/tigerisland45/article/details/81529661