40分求助!!!
查看原帖
40分求助!!!
1153981
LINZJ0622楼主2023/12/28 16:14
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	long long n = 0;
	long long R[200] = { 0 };
	scanf("%ld %ld", &n, &R[0]);
	int i = 0;
	for (i = 1; i < n; i++)
	{
		R[i] = (R[i - 1] * 6807 + 2831) % 201701;
	}
	long long sum = 0;
	long long a[200] = { 0 };
	for (i = 0; i < n; i++)
	{
		a[i] = R[i] % 10;
	}
	long long xx = a[0];
	for (i = 1; i < n - 1; i++)
	{
		if (a[i] < xx)
		{
			sum = sum + (xx - a[i]);
		}
		else if (a[i] >= xx)
		{
			xx = a[i];
		}
	}
	i = n - 2;
	if (a[n - 1] < xx)
	{
		while (1)
		{
			if (a[i] == xx)
			{
				break;
			}
			sum = sum - (xx - a[i]);
			i = i - 1;
		}
	}
	printf("%ld", sum);
	return 0;
}
2023/12/28 16:14
加载中...