Expression (playing table AC Dafa (funny))

Demand   value, wherein, k, p are less than 10 . 9 positive integer. Which ensure that p is a prime number.

 

A number of topics see this, I thought: playing table now!

Thus any number 13 takes a mass, k is 1, 2 ......

This discovery is playing out (not modulo):

91 195 312 442 585 741 (k = 1~6)

However, this is what the law? ?

They can be found in addition to 13.

Happy they are in addition to 13:

71,524,344,537 has been found that is not the law?

A change of prime numbers and found that they all meet the law

So bold assumption that the law

For a prime number p, k is the first item is a (p + 1) / 2, an arithmetic prefixed tolerance and the number of columns.

But also found that if k> (p + 1) / 2, it is P 2 taken after the first item and the remainder is equal to pk.

Then for p = 2 special sentenced click. code show as below:

#include <cstdio>
#include <iostream>
using namespace std;

inline void read (int& s) {
	s = 0;
	static char c = getchar ();
	while (c < '0' || c > '9') c = getchar ();
	while (c >= '0' && c <= '9') s = (s << 3) + (s << 1) + (c & 15), c = getchar ();
	return ;
}

typedef long long ll;
ll k, p, MOD;

inline ll mult (ll p, ll x) {
	ll s = 0;
	while (x) {
		if (x & 1) s = (s + p) % MOD;
		p = (p + p) % MOD;
		x >>= 1;
	}
	return s;
}

int main () {
	cin >> k >> p;
	MOD = 1ll * p * p;
	if (p & 1) {
		k %= p; 
		if (k > p / 2) k = p - k;
		ll a = p + 1 >> 1;
		ll x = k * a % MOD;
		ll y = k * (k - 1) / 2;
		x = (x + y) % MOD;
		cout << mult (x, p) << '\n';
	}
	else putchar ((k & 1) + '0'), putchar ('\n');
	return 0;
}

  

Guess you like

Origin www.cnblogs.com/Squirrel-Vae/p/11600556.html
ac