杭电1098--f(x)=5*x^13+13*x^5+k*a*x

                    伊格内修斯的难题

问题描述
伊格内修斯数学很差,他落在一个谜问题,所以他别无选择,只能对艾迪的吸引力。这个问题描述:f(x)= 5 * x ^ 13 + 13 * x ^ 5 + k * * x,输入一个nonegative整数k(k < 10000),找到最小nonegative整数,使任意整数x,65 | f(x)
不存在,然后打印“不”。

输入
输入包含多个测试用例。每个测试用例由nonegative整数k,在样例输入更多细节。

输出
输出包含一个字符串“不”,如果你不能找到一个,或者你应该输出一行包含一个。更多细节的示例输出。

样例输入
11
100
9999

样例输出
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了

代码:

# include <iostream>
# include <cstdio>

using namespace std;

int main(){

     int n,m,i,j,k;

     while(scanf("%d",&k)!=EOF){
        for(i=1;i<=65;i++){
            if((18+k*i)%65==0){
                break;
            }
        }

        if(i>65){
            printf("no\n");
        }else{
            printf("%d\n",i);
        }
     } 


    return 0;
}
杭电电子设计<svg width="800" height="600" viewBox="0 0 800 600" xmlns="http://www.w3.org/2000/svg"> <!-- 背景 --> <rect width="800" height="600" fill="#f8f8f8"/> <!-- 标题 --> <text x="400" y="30" font-family="Arial" font-size="20" text-anchor="middle" fill="#333">温度测试装置电路设计原理图</text> <!-- STM32F103C8T6微控制器 --> <rect x="300" y="150" width="200" height="100" fill="#e6f2ff" stroke="#3366cc" stroke-width="2"/> <text x="400" y="200" font-family="Arial" font-size="14" text-anchor="middle" fill="#333">STM32F103C8T6</text> <!-- DS18B20温度传感器 --> <rect x="150" y="250" width="100" height="50" fill="#ffe6e6" stroke="#cc3333" stroke-width="2"/> <text x="200" y="280" font-family="Arial" font-size="14" text-anchor="middle" fill="#333">DS18B20</text> <!-- LCD1602显示屏 --> <rect x="550" y="250" width="150" height="80" fill="#e6ffe6" stroke="#33cc33" stroke-width="2"/> <text x="625" y="290" font-family="Arial" font-size="14" text-anchor="middle" fill="#333">LCD1602</text> <!-- 按键模块 --> <rect x="150" y="350" width="100" height="80" fill="#fff6cc" stroke="#cc9933" stroke-width="2"/> <text x="200" y="380" font-family="Arial" font-size="14" text-anchor="middle" fill="#333">按键模块</text> <!-- LED指示灯 --> <rect x="550" y="350" width="100" height="50" fill="#ffe6ff" stroke="#cc33cc" stroke-width="2"/> <text x="600" y="380" font-family="Arial" font-size="14" text-anchor="middle" fill="#333">LED指示灯</text> <!-- 电源部分 --> <rect x="350" y="450" width="100" height="80" fill="#f2f2f2" stroke="#666666" stroke-width="2"/> <text x="400" y="480" font-family="Arial" font-size="14" text-anchor="middle" fill="#333">电源部分</text> <!-- 连接线 --> <!-- DS18B20连接到STM32 --> <line x1="250" y1="275" x2="300" y2="200" stroke="#333" stroke-width="1.5"/> <text x="275" y="230" font-family="Arial" font-size="12" text-anchor="middle" fill="#333">PA1 (DQ)</text> <!-- LCD1602连接到STM32 --> <line x1="550" y1="290" x2="500" y2="200" stroke="#333" stroke-width="1.5"/> <text x="525" y="240" font-family="Arial" font-size="12" text-anchor="middle" fill="#333">PB0-PB7</text> <!-- 按键模块连接到STM32 --> <line x1="250" y1="390" x2="300" y2="250" stroke="#333" stroke-width="1.5"/> <text x="275" y="320" font-family="Arial" font-size="12" text-anchor="middle" fill="#333">PA5-PA8</text> <!-- LED指示灯连接到STM32 --> <line x1="650" y1="375" x2="500" y2="250" stroke="#333" stroke-width="1.5"/> <text x="575" y="320" font-family="Arial" font-size="12" text-anchor="middle" fill="#333">PB9-PB10</text> <!-- 电源连接 --> <line x1="400" y1="530" x2="400" y2="580" stroke="#333" stroke-width="1.5"/> <text x="400" y="560" font-family="Arial" font-size="12" text-anchor="middle" fill="#333">5V输入</text> <line x1="400" y1="530" x2="300" y2="200" stroke="#333" stroke-width="1.5"/> <line x1="400" y1="530" x2="200" y2="275" stroke="#333" stroke-width="1.5"/> <line x1="400" y1="530" x2="625" y2="290" stroke="#333" stroke-width="1.5"/> <line x1="400" y1="530" x2="200" y2="390" stroke="#333" stroke-width="1.5"/> <line x1="400" y1="530" x2="600" y2="375" stroke="#333" stroke-width="1.5"/> <!-- 接地符号 --> <path d="M400,580 L390,590 L400,600 L410,590" stroke="#333" stroke-width="1.5" fill="none"/> <!-- 组件详细说明 --> <text x="100" y="500" font-family="Arial" font-size="12" fill="#333">DS18B20连接: DQ-PA1, VCC-5V, GND-GND</text> <text x="100" y="520" font-family="Arial" font-size="12" fill="#333">LCD1602连接: DB0-DB7-PB0-PB7, RS-PB10, RW-PB11, E-PB12</text> <text x="100" y="540" font-family="Arial" font-size="12" fill="#333">按键连接: KEY1-KEY4-PA5-PA8, VCC-5V, GND-GND</text> <text x="100" y="560" font-family="Arial" font-size="12" fill="#333">LED连接: LED1-LED2-PB9-PB10, GND-GND</text> </svg>生成电路原理图
最新发布
06-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值