HDU 1098 Ignatius's puzzle 【数学(特殊值总结) Or 规律(瞎搞)】

By | 02月06日
Advertisement

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+kax,输入一个数k,判断它是否满足存在a,使x取任意值满足f(x)为65的倍数,存在则输出最小的a,不存在则输出no

思路:现假设存在这个数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了)

AC代码:

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int n, ans;
    while(~scanf("%d",&n))
    {
        ans = 0;
        for(int i = 1; i <= 65; ++i)
        {
            if((18 + n * i) % 65 == 0)
            {
                ans = i;
                break;
            }
        }
        if(ans) cout << ans << endl;
        else cout << "no" << endl;
    }
    return 0;
}

为啥做这种题?不要问我,因为我也不知道我在做什么TAT

Similar Posts:

  • HDU 1098 Ignatius&#39;s puzzle

    Ignatius's puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8526 Accepted Submission(s): 5907 Problem Description Ignatius is poor at math,he falls across a puzzle problem,so he has no choic

  • HDU 1098 Ignatius&#39;s puzzle(数论-其它)

    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

  • Hdu 1098 Ignatius&amp;amp;#39;s puzzle

    1.一开始读题,65|f(x)是什么意思都不清楚,最后百度才知道是f(x)能被65整除. 2.而且写这题完全没有思路,数论不好,我是根据网上的思路写的. 思路:则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整除.那么

  • HDOJ 1098 Ignatius&#39;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

  • HDU 1027 Ignatius and the Princess II [康托逆展开]【数学】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1027 --------------–. Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7182 Accepted Submission(s): 4264 Problem Descript

  • hdu 1097 A hard puzzle 快速幂取模

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1097 分析:简单题,快速幂取模, 由于只要求输出最后一位,所以开始就可以直接mod10. /*A hard puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 33036 Accepted Submission(s): 11821 Pr

  • HDU 1028 Ignatius and the Princess III(母函数)

    题目:HDU-1028 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 题目: Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 16806 Accepted Submission(s): 11830 Problem Descri

  • 【搜索之BFS + 优先队列】杭电 hdu 1026 Ignatius and the Princess I

    /* THE PROGRAM IS MADE BY PYY */ /*----------------------------------------------------------------------------// Copyright (c) 2012 panyanyany All rights reserved. URL : http://acm.hdu.edu.cn/showproblem.php?pid=1026 Name : 1026 Ignatius and the Pri

  • hdu 4586 Play the Dice 数学 概率

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4586 题意: 给一个n面的骰子,每一面有一个分数,掷到的话可以得到那个分数 其中有m个面,当你掷到这些面的时候可以再掷一次 求得分的数学期望 思路: 每轮得分的期望 乘以 轮数的期望 每轮得分的期望 = 各个面的平均分 = sum / n; 轮数期望 = 1 + m/n + (m/n)^2 + ... = n - m / n 所以ans = sum / (n - m) ,其中 n!=m 要特判一些情

  • HDU 1097 A hard puzzle【快速幂取模运算】

    A hard puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 30984 Accepted Submission(s): 11109 Problem Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,h

Tags: