Problem G: 深入浅出学算法008-求佩尔方程的解
2024-08-27 02:41:37
Description
求关于x y的二次不定方程的解 x2-ny2=1
Input
多组输入数据,先输入组数T 然后输入正整数n(n<=100)
Output
对于每组数据输出一行,求y<=10000的最小正整数解 ,输出y的值,如果在此范围内没有解则输出No
Sample Input
1
73
Sample Output
No
#include <stdio.h>
#include <math.h>
int main()
{
int t,n;
int i,j;
int a,b; while(scanf("%d",&t)!=EOF)
{
while(t--)
{
int flag=;
scanf("%d",&n);
for(i=;i<=;i++)
{
if((int)sqrt(i*i*n+)*(int)sqrt(i*i*n+)==n*i*i+)
{
printf("%d\n",i);
flag=;
break;
}
}
if(flag==)
{
printf("No\n");
}
}
}
return ;
}
最新文章
- Hibernate 系列 08 - 对象识别机制
- JS中class和id的区别
- c#datagirdview ,用DataSource 方式赋值,然后更新出问题问题
- select值的获取及修改
- Dynamics AX Read OLEDB
- [C++][重载]
- seleniumAccessors
- python学习小结8:I/O
- Arch linux安装
- 一道面试题与Java位操作 和 BitSet 库的使用
- 处理PHP中字符串的常用操作及函数
- 751D·PARK北京时尚设计广场_百度百科
- VS插件
- XML学习经验实例总结2
- 怎样解决if __name__ == ";__main__";:下面的代码没有执行的问题
- Chapter 5 Blood Type——6
- H5 28-优先级之权重问题
- cocos2dx-lua 延迟调用函数和定时器
- hdu1002-A + B Problem II-(java大数)
- python3 解决zip解压中文乱码问题,亲测可用, ZipFile
热门文章
- NYOJ 93 汉诺塔 (数学)
- Redis笔记之常用命令
- 大聊Python----装饰器
- 【译】第一篇 SQL Server代理概述
- DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead extract-text-webpack-plugin 提取css报错
- android 图片旋转 移动 放大缩小
- UML相关说明
- 9 - Python函数定义-位置参数-返回值
- linux配置samba服务【原创】
- anychat安装