大数的快速求余算法

大数的求余,相加,相减算法A plus B+: Now give you two positive integers, A, B, and C. Please count A plus B, then modulo C.InputInput will consist of multiple problem instances. The first line of the in
摘要由CSDN通过智能技术生成

大数的求余,相加,相减算法

  • A plus B+:
    Now give you two positive integers, A, B, and C. Please count A plus B, then modulo C.

Input

Input will consist of multiple problem instances. The first line of the input will contain a single integer indicating the number of problem instances.
Each instance will consist of a single line of 0< A~ ~B~ ~C<10^40

Output

For each problem instance, output a single line containing the answer.

Sample input

2
1 2 100
5 6 10

Sample output

3
1
  • 在实际写题的时候有意避过了去模拟的过程,不过做完之后还是觉得有必要模拟一波。就花了一下午时间去写这个东东。
  • 实际大数的求余数算法,就是花时间去写,也没有多难。判断俩个数的大小,我采用的是相减。算出结果。
#include <bits/stdc++.h>

using namespace std;

void big_plus(int numa[],int numb[]);//大数的加法,实现是从末尾来存放个位,然后依次递推
void big_mod(int numa[],int numb[]);//大数的求余算法,实际实现是减法,当位数相差比较大时,先减去一个大倍数的b,减少算法上面的时间消耗
void init(int a[],int b[],int c[],char ca[],char cb[],char cc[]);//数据初始化
void restore(int numa[],char a[]);//将字符串,存储到数组中
bool judge(int
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值