import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
String s, s1;
s = reader.next();
s1 = reader.next();
BigInteger result = new BigInteger("0");
BigInteger one = new BigInteger(s);
BigInteger two = new BigInteger(s1);
System.out.println(one.divide(two) + " " + one.remainder(two));
}
}
运用string类型数据处理无限制长度的数字字符序列,从而可以转化为数字进行操作
#include<iostream>
using namespace std;
int main(){
string s;
int i,sum=0,item=0,n;
cin>>s>>n;
for(i=0;i<s.length();i++){
item=s[i]-'0'+sum*10;
if(i==0&&item/n==0);
else cout<<item/n;
if(s.length()-1==0&&item/n==0)
cout<<0;
sum=item%n;
}
cout<<' '<<sum;
return 0;
}