这里记一下两种方法
1、字符串
#include
#include
#include
using namespace std;
typedef long long ll;
int main(){
char num[100005];
int i, j, x;
while(~scanf("%s %d", num,&x)){
ll ans = 0;
for(i = 0; i < strlen(num); ++i){
ans = ans*10 + (num[i]-'0');
ans %= x;
}
printf("%lld
",ans);
getchar();
}
return 0;
}
1、JAVA(本人不擅长JAVA。。。选自大牛博客)
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main
{
public static void main(String args[])
{
BigInteger big1 = new BigInteger("0");
BigInteger big2 = new BigInteger("0");
Scanner cin = new Scanner (System.in);
while(cin.hasNext())
{
big1 = cin.nextBigInteger();
big2 = cin.nextBigInteger();
big1 = big1.remainder(big2);
System.out.println(big1);
}
}
}
JAVA代码原地址:
http://m.blog.csdn.net/ysc504/article/details/8818279