⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pku2305.java

📁 这是ACM 方面的资料 是PKU的 北京大学的出来的
💻 JAVA
字号:
import java.io.*;
import java.util.*;
import java.math.BigInteger;

class Main
{
	public static void main(String args[]) throws Exception
	{
		Scanner cin=new Scanner(System.in);
		String s;
		int base, i, l;
		BigInteger bg1, bg2, bg;
		int ans[] = new int[1000];
		
		while(true)
		{
			base = cin.nextInt();
			if (base == 0)
			{
				break;
			}
			
			s = cin.next();
			bg1 = new BigInteger(s, base);
			
			s = cin.next();
			bg2 = new BigInteger(s, base);
			
			bg = bg1.mod(bg2);
			
			if(bg.equals(BigInteger.ZERO))
			{
				System.out.println(0);
				continue;
			}
			
			for (i = 0; bg.equals(BigInteger.ZERO) == false; i++)
			{
				ans[i] = bg.mod(BigInteger.valueOf(base)).intValue();
				bg = bg.divide(BigInteger.valueOf(base));
			}
			
			i--;
			while (i >= 0)
			{
				System.out.print(ans[i]);
				i--;
			}
			System.out.println();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -