链接: https://pan.baidu.com/s/108MeTLiz3iqYZCvcdbePIw
提取码: b5sn
链接: https://pan.baidu.com/s/108MeTLiz3iqYZCvcdbePIw
提取码: b5sn
using System;
namespace ConsoleApp1
{
class Program
{
public static int Montgomery(int a, string b, int c)
{
if (b.Length == 0)
{
return 1;
}
int k = a % c;
if (b[b.Length - 1] == '0')
{
a = (k * k) % c;
b = b.Substring(0, b.Length - 1);
return Montgomery(a, b, c);
}
else
{
char[] temp = b.ToCharArray();
temp[b.Length - 1] = '0';
b = new string(temp);
return (k * Montgomery(a, b, c)) % c;
}
}
static void Main(string[] args)
{
String a = Console.ReadLine();
String b = Console.ReadLine();
int aa;
if(a.Length > 2)
{
aa = int.Parse(a.Substring(a.Length - 2));
}
else
{
aa = int.Parse(a);
}
string c = Montgomery(aa, b, 100).ToString().PadLeft(2, '0');
Console.WriteLine(c);
}
}
}