http://acm.hdu.edu.cn/showproblem.php?pid=1111

复数除法:

 #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int a[];
__int64 n;
int x1,y1,b1,b2;
int t1;
bool flag; void dfs(int cnt)
{
if(cnt>) return;
if(x1==&&y1==)
{
flag=true;
t1=cnt;
return;
}
for(int i=; i*i<=n; i++)
{
if(flag) return;
__int64 xx=(x1-i)*b1+y1*b2;
__int64 yy=y1*b1-(x1-i)*b2;
if(xx%n==&&yy%n==)
{
x1=xx/n;
y1=yy/n;
a[cnt]=i;
dfs(cnt+);
}
}
} int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d%d",&x1,&y1,&b1,&b2);
n=b1*b1+b2*b2;
flag=false;
dfs();
if(!flag)
{
printf("The code cannot be decrypted.\n");
}
else
{
printf("%d",a[t1-]);
for(int i=t1-; i>=; i--)
{
printf(",%d",a[i]);
}
printf("\n");
}
}
return ;
}

hdu 1111 Secret Code的更多相关文章

  1. hdu.1111.Secret Code(dfs + 秦九韶算法)

    Secret Code Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. HDU 1111 Secret Code(数论的dfs)

    Secret Code Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit ...

  3. HDU 1111 Secret Code (DFS)

    题目链接 题意 : 给你复数X的Xr和Xi,B的Br和Bi,让你求一个数列,使得X = a0 + a1B + a2B2 + ...+ anBn,X=Xr+i*Xi,B=Br+Bi*i : 思路 : 首 ...

  4. [swustoj 679] Secret Code

    Secret Code 问题描述 The Sarcophagus itself is locked by a secret numerical code. When somebody wants to ...

  5. Android Secret Code

    我们很多人应该都做过这样的操作,打开拨号键盘输入*#*#4636#*#*等字符就会弹出一个界面显示手机相关的一些信息,这个功能在Android中被称为android secret code,除了这些系 ...

  6. Android 编程下的 Secret Code

    我们很多人应该都做过这样的操作,打开拨号键盘输入 *#*#4636#*#* 等字符就会弹出一个界面显示手机相关的一些信息,这个功能在 Android 中被称为 Android Secret Code, ...

  7. The secret code

    The secret code Input file: stdinOutput file: stTime limit: 1 sec Memory limit: 256 MbAfter returnin ...

  8. 洛谷 P3102 [USACO14FEB]秘密代码Secret Code 解题报告

    P3102 [USACO14FEB]秘密代码Secret Code 题目描述 Farmer John has secret message that he wants to hide from his ...

  9. Secret Code

    Secret Code 一.题目 [NOIP模拟赛A10]Secret Code 时间限制: 1 Sec  内存限制: 128 MB 提交: 10  解决: 6 [提交][状态][讨论版] 题目描述 ...

随机推荐

  1. JavaScript中的Array对象

    1.创建Array对象创建Array对象的语法var 数组名 = new Array();定义数组之后,就需要向数组中添加元素,格式如下数组名[<下标>]=值: 2.Array对象属性Ar ...

  2. Delphi 函数指针(函数可以当参数)

    首先学习: 指向非对象(一般的)函数/过程的函数指针 Pascal 中的过程类型与C语言中的函数指针相似,为了统一说法,以下称函数指针.函数指针的声明只需要参数列表:如果是函数,再加个返回值.例如声明 ...

  3. About Adultism and why things ar the way they are

    About - Adultism About Adultism and why things ar the way they are In this page we will try to clari ...

  4. 关于cvAdsDiffS的那些事

    cvAbsDiffS 计算数组元素与数量之间差的绝对值 void cvAbsDiffS( const CvArr* src, CvArr* dst, CvScalar value ); #define ...

  5. [WPF] 将普通的Library工程,改造成WPF Custom Control 的Library

    1. 添加References PresentationCore PresentationFramework System.Xaml WindowsBase2. 修改AssemblyInfo.xsus ...

  6. github atom 试用

    github的编辑器atom 1.0已经出来了,在https://atom.io/ 我之前在win上一直用notepad++写了两年脚本.最近改写lua了,项目组统一用的sublime text.su ...

  7. 获取文本区域(textarea)行数【换行获取输入用户名个数】

    需求:输入会员名,一行一个,最多可输入1000个 效果:

  8. Excel函数大全

    我们在使用Excel制作表格整理数据的时候,经常要用到它的函数功能来自己主动统计处理表格中的数据.这里整理了Excel中使用频率最高的函数的功能.用法,以及这些函数在实际应用中的实例剖析,并配有具体的 ...

  9. 验证docker的Redis镜像也存在未授权访问漏洞

    看到了这篇老外的博客:Over 30% of Official Images in Docker Hub Contain High Priority Security Vulnerabilities于 ...

  10. 只包含schema的dll生成和引用方法

    工作中,所有的tools里有一个project是只包含若干个schema的工程,研究了一下,发现创建这种只包含schema的dll其实非常简单. 首先,在visual studio-new proje ...