A/B
来源:互联网 发布:为什么凌晨五点醒 知乎 编辑:程序博客网 时间:2024/06/07 08:41
A/B
Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 22 Accepted Submission(s) : 17
Font: Times New Roman | Verdana |Georgia
Font Size: ← →
Problem Description
要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。
Input
数据的第一行是一个T,表示有T组数据。
每组数据有两个数n(0 <= n < 9973)和B(1 <= B <= 10^9)。
每组数据有两个数n(0 <= n < 9973)和B(1 <= B <= 10^9)。
Output
对应每组数据输出(A/B)%9973。
Sample Input
21000 5387 123456789
Sample Output
79226060
Author
Source
HDU 2007-1 Programming Contest
#include<stdio.h>void gcd(int a, int b,int &x,int &y) // a*x+b*y==1 如果要求 a*x1+b*y1==n 中的 x1 只需要 x1=x*n{if (b == 0){x = 1;y = 0;return; // return a; 求最大公约数 }elsegcd(b, a%b,x,y);int sum=x;x = y;y = sum - a / b*y;}int main(){int a,b=9973, x, y,n,t;scanf("%d", &t);while(t--){scanf("%d%d", &n, &a);gcd(a ,b,x,y);x *= n; // x a*x+b*y==1 中的 xx = (x %b + b) % b; // 防止 x 为负数printf("%d\n",x);}return 0;}
0 0
- a>b?a:b
- a+b
- a+++b
- A + B
- A+B
- A+B
- {A} + {B}
- a+++b
- A+B
- A-B
- A+B
- A + B
- A|B?
- A+B
- A + B
- A+B
- A + B
- A+B
- 拷贝文件
- spring与jbpm整合遇到的一个错误
- 802.11之WEP
- LoadRunner解决动态验证码问题
- FFmpeg API
- A/B
- Android SlidingMenu Demo 环境搭建
- 现代操作系统学习笔记——分页存储
- js_撞球游戏
- Cocos2dx场景切换效果汇总
- 从一道百度面试题到分析输入url到页面返回的过程(或者查询返回过程)
- Romantic
- H面试程序(0):字符串一些常用函数的实现
- hibernate 中的hql 语句累积