zoukankan      html  css  js  c++  java
  • hdu 1098 Ignatius's puzz

    有关数论方面的题要仔细阅读,分析公式。

    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
     
    Author
    eddy
     
     
     

    题目大意:方程f(x)=5*x^13+13*x^5+k*a*x;输入任意一个数k,是否存在一个数a,对任意x都能使得f(x)能被65整出;输入a;

    解题报告:假设存在这个数a ,因为对于任意x方程都成立,所以,当x=1时f(x)=18+ka;有因为f(x)能被65整出,这可得出f(x)=n*65;

    即:18+ka=n*65;若该方程有整数解则说明假设成立。

    所以,只要找到a,使得18+k*a能被65整除,也就解决了这个题目.

     1 #include<iostream>
     2 using namespace std;
     3 int main()
     4 {
     5     int k,i;
     6     while(scanf("%d",&k)!=EOF)
     7     {
     8         for(i=1;i<=10000;i++)
     9         {
    10             if((18+k*i)%65==0){printf("%d
    ",i);break;}
    11         }
    12         if(i>10000)printf("no
    ");
    13     }
    14     return 0;
    15 }
     
  • 相关阅读:
    Sublime Text 3 Build 3143 可用License
    npm安装cnpm报错
    使用proxy来简单的实现一个观察者
    时间倒计时提醒
    JavaScript设计模式
    异步方法(promise版)出错自调用
    co模块源码学习笔记
    go new() 和 make() 的区别
    广度优先搜索算法
    并发和并行有什么区别?(转)
  • 原文地址:https://www.cnblogs.com/wangmengmeng/p/4710896.html
Copyright © 2011-2022 走看看