ss.cpp

来自「这是基于密码学的几个编程,很基础,但却是密码学中常用到的」· C++ 代码 · 共 35 行

CPP
35
字号
#include <stdio.h>
//#include <math.h>

void main()
{
	int a , r, b;
	int bottom = 12996;
	int A = 1;
	a = 227;
	int n[10];
	int i = 0;
	while( a != 0 )
	{
		b = a / 2;
		r = a % 2;
		n[i] = r;
		i ++;
		a = b;
	}

	for(int k = 0; k < i; k ++)
	{
		if(n[k] != 0)
		{
			A = (A * bottom) % 37909;
			bottom = (bottom * bottom) % 37909;
		}
		else
		{
			bottom = (bottom * bottom) % 37909;
		}
	}
	printf("(12996)227 ≡  %d (mod 37909) \n", A);
}

⌨️ 快捷键说明

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