费马小定理例题汇总
hdu 6440 Dream
Freshmen frequently make an error in computing the power of a sum of real numbers, which usually origins from an incorrect equation $ (m+n)^p=m^p+n^p $, where m,n,p are real numbers. Let’s call it ‘’Beginner’s Dream’’.
For instance, $ (1+4)^2=5^2=25 $, but $ 1^2+4^2=17\neq25$.
Moreover, $ \sqrt{9+16}= \sqrt{25}=5 $, which does not equal $ 3+4=7 $.
Fortunately, in some cases when p is a prime, the identity $(m+n)^p=m^p+n^p $ holds true for every pair of non-negative integers m,n which are less than p, with appropriate definitions of addition and multiplication.
You are required to redefine the rules of addition and multiplication so as to make the beginner’s dream realized.
Specifically, you need to create your custom addition and multiplication, so that when making calculation with your rules the equation $ (m+n)^p=m^p+n^p $ is a valid identity for all non-negative integers m,n less than p. Power is defined asObviously there exists an extremely simple solution that makes all operation just produce zero. So an extra constraint should be satisfied that there exists an integer $q(0<q<p)$ to make the set ${q^k|0<k<p,k\in\mathbb{Z}}$ equal to ${k|0<k<p,k\in\mathbb{Z}}$. What’s more, the set of non-negative integers less than p ought to be closed under the operation of your definitions.
(扩展)欧拉定理例题汇总
(扩展)中国剩余定理例题汇总
(扩展)欧几里得算法模板
威尔逊定理例题汇总
hdu 5391 Zball in Tina Town
Problem Description
Tina Town is a friendly place. People there care about each other.
Tina has a ball called zball. Zball is magic. It grows larger every day. On the first day, it becomes 1 time as large as its original size. On the second day,it will become 2 times as large as the size on the first day. On the n-th day,it will become n times as large as the size on the (n-1)-th day. Tina want to know its size on the (n-1)-th day modulo n.