hdu 3579:Hello Kiki (线性同余方程组求正整数解)
来源:互联网 发布:网络的攻击与防范 编辑:程序博客网 时间:2024/05/02 00:04
Hello Kiki
Problem Description
Hello Kiki is such a lovely girl that she loves doing counting in a different way. For example, when she is counting X coins, she count them N times. Each time she divide the coins into several same sized groups and write down the group size Mi and the number of the remaining coins Ai on her note.
One day Kiki's father found her note and he wanted to know how much coins Kiki was counting.
One day Kiki's father found her note and he wanted to know how much coins Kiki was counting.
Input
The first line is T indicating the number of test cases.
Each case contains N on the first line, Mi(1 <= i <= N) on the second line, and corresponding Ai(1 <= i <= N) on the third line.
All numbers in the input and output are integers.
1 <= T <= 100, 1 <= N <= 6, 1 <= Mi <= 50, 0 <= Ai < Mi
Each case contains N on the first line, Mi(1 <= i <= N) on the second line, and corresponding Ai(1 <= i <= N) on the third line.
All numbers in the input and output are integers.
1 <= T <= 100, 1 <= N <= 6, 1 <= Mi <= 50, 0 <= Ai < Mi
Output
For each case output the least positive integer X which Kiki was counting in the sample output format. If there is no solution then output -1.
Sample Input
2214 575 56519 54 40 24 8011 2 36 20 76
Sample Output
Case 1: 341Case 2: 5996
解题思路:参考poj 2891 Strange Way To Express Integers(线性同余方程组),题目链接
http://blog.csdn.net/u012717411/article/details/43016705
注意0<=A[i],A[i]可均为0,即X可能为零,这在许多问题中是不会出现的,在这里是个坑。。。。。要特判一下
参考代码:
0 0
- hdu 3579:Hello Kiki (线性同余方程组求正整数解)
- hdu 3579 Hello Kiki(求解线性同余模方程组的正整数解模板题)
- hdu 3579 Hello Kiki(一元线性同余方程组)
- HDU 3579 Hello Kiki 解同余方程组
- Hello Kiki hdu 3579 求解一元线性同余方程组ps:中国剩余定理
- HDU OJ 3579 Hello Kiki(线性同余方程组的合并求解)
- Hdu 3579 Hello Kiki(同余模方程组)
- HDU3579 Hello Kiki 解同余方程组
- hdu 1573: X问题(线性同余方程组求正整数解的个数)
- HDU3579 Hello Kiki【一元线性同余方程组】
- hdu 3579 Hello Kiki(线性同余方程)
- hdu 3579 Hello Kiki 同余
- HDU3579 Hello Kiki 解线性同余方程的应用
- 解线性同余方程组
- 解线性同余方程组
- Hdu 1573 线性同余方程组
- 解一元线性同余方程组模板
- 解一元线性同余方程组
- Linux流量监控工具 - iftop (最全面的iftop教程)
- POJ 3764 The xor-longest Path 字典树求最大异或
- 编写一个函数 int count_chars(char const *str,char const *chars) 函数应该在第一个参数中进行查找, 并返回匹配第二个参数所包含的字符的数量。
- Android中Path类的lineTo方法和quadTo方法画线的区别
- iOS多线程
- hdu 3579:Hello Kiki (线性同余方程组求正整数解)
- Field类的setAccessible()方法
- iOS开发- tintColor 与backgroundColor区别研究
- Win7下modelsim编译Xilinx库
- 职业院校人体解剖学实验室文化建设研究
- 第2章 2.10 Servlet介绍
- linux学习之shell脚本 ------- 控制流结构
- JVM学习笔记(一)------基本结构
- Java虚拟机(六):Java编程和执行过程