Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

A^B%C ÒªÓÃC++д ÎÒÖ»»áC++

(A^B)%C

Time Limit:1000MS Memory Limit:65536K
Total Submit:263 Accepted:35 

Description 

Naruto' faith is never give up, so I hope you can persist in ACM. ACM is not a shortcut to success, there are many obstacles you should overcome, but only overcome them you can become more powerful ! 
First, you need to overcome English. Now this problem. 


Input 

The input consist of three integers A,B,C; 1<= A <=10000; 1<= B <=10^9; 1<=C<=10000; three 0 sign the end of the input.

Output 

The output will be a single integer——(A^B)%C. For example,A=2,B=4,C=5, then the result is (2^4)%5 = (2*2*2*2)%5 = 1.

Sample Input 


2 2 3
3 3 4
4389 99999999 1303
0 0 0


Sample Output 


1
3
698

ǰÁ½¸ö¶ÔÉÏÁË£¬µÚÈý¸öû¶ÔÉÏ£¬´úÂëÓ¦¸ÃûÓÐÎÊÌâ²Å¶Ô
ÊÔÁ˺ܶàÊý¾Ý£¬LZ¿´ÏÂÄãÌṩµÄÊý¾ÝºÍ´ð°¸¶¼Ã»ÎÊÌâÂð£¿
C/C++ code:
#include <iostream>
using namespace std:

typedef long unsigned int LUINT;

LUINT remainder(LUINT a, LUINT b, LUINT c)
{
a %= c;
bool bEven = (0==b%2);
LUINT tmp = a;
for (LUINT i=bEven?b:b-1; i>=2; i/=2)
{
a = (a*a % c);
}
return bEven? a%c : (a*tmp)%c;
}


Ïà¹ØÎÊ´ð£º

C/C++ÀïÆÁshift+f10¼üÒªÔõôд£¡ - C/C++ / C++ ÓïÑÔ

SHIFT¼ÓF10ÓëÄǸö¼üÓÒctrl±ßÉϵÄÄǸö¼ü¹¦ÄÜÒ»Ñù£¬ÏëÆÁÕâ¸ö
µ«²»ÖªÒªÔõôдÄǸö×éºÏ¼ü£¡
ÓÐûÄĸö´óÏÀ·ÅÒ»¶ÎÕâ¸öµÄ´úÂë»òдһ¶Î
http://topic.csdn.net/u/20090609/15/7dc9fb70-243f-4070-9cfd-34e48b66e6c6.html ......

C/C++ÖÐÓÐûÓиñʽ»¯UÅ̵ĺ¯Êý - C/C++ / C++ ÓïÑÔ

´ó¼ÒºÃ£º
ÎÒÏëʵÏÖ¼ì²âµ½²åÈëSD¿¨ºó×Ô¶¯½«SD¿¨¸ñʽ»¯µÄ¹¦ÄÜ£¬²»ÖªC/C++ÖÐÓÐûÓиñʽ»¯UÅ̵ĺ¯Êý£¿
ÁíÍ⣬ÎÒ²»ÏëʹÓÃSHFormatDrive£¬ÒòΪÕâ¸öº¯Êý»áµ¯³öÊÇ·ñÒª¸ñʽ»¯µÄÌáʾ¿ò£¬ÎÒÐèÒªµÄÊÇϵͳ×Ô¶¯¸ñʽ»¯£¬¶ø²Ù×÷Õß² ......

c¾²Ì¬±àÒëÁíÒ»¸öÎļþ¼ÐµÄ¿âº¯Êý - C/C++ / CÓïÑÔ

ÔÚ¸ùĿ¼/libÖдæ·ÅÒ»¸ölog.c£¬log.h£¬²¢ÓÃÏÂÃæµÄÓï¾ä£º
gcc -c log.c
ar crv liblog.a log.o
±àÒë³öÒ»¸öliblog.a¾²Ì¬¿â£¬È»ºóÔÚÎļþ¼Ð£º/testfileÖд´½¨Ò»¸ötest.cºÍtestc.c£¬test.cÖÐÒýÓÃÁËtestc.cÖж¨ÒåµÄ·½·¨ ......

ÇóÖú£ºC´úÂëchange toVB´úÂë - VB / »ù´¡Àà

ͦ·±Ëö£¬Ö®Ç°·¢µÄÌû×Ó£¬·Öֵ̫µÍÏÖÔÚÖØ·¢Ò»¸ö¡£»¶Ó­¸÷λ´óÏÀ~~
#include "stdlib.h"
#include "math.h"
#include "stdio.h"
float objfx(float x[]);
void constraint(float x[] ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ