【SGU】117. Counting 快速幂
来源:互联网 发布:12306数据库 百度网盘 编辑:程序博客网 时间:2024/06/05 01:12
传送门:【SGU】117. Counting
题目分析:快速幂对k取模,结果为0则ans++。
代码如下:
#include <map>#include <vector>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std ;typedef long long LL ;#pragma comment ( linker , "/STACK:16777216" )#define rep( i , a , b ) for ( int i = ( a ) ; i < ( b ) ; ++ i )#define For( i , a , b ) for ( int i = ( a ) ; i <= ( b ) ; ++ i )#define rev( i , a , b ) for ( int i = ( a ) ; i >= ( b ) ; -- i )#define clr( a , x ) memset ( a , x , sizeof a )int n , m , k ;int pow ( int a , int b ) {int res = 1 , tmp = a ;while ( b ) {if ( b & 1 ) res = res * tmp % k ;tmp = tmp * tmp % k ;b >>= 1 ;}return res ;}void solve () {int x , ans = 0 ;For ( i , 1 , n ) {scanf ( "%d" , &x ) ;if ( !pow ( x , m ) ) ++ ans ;}printf ( "%d\n" , ans ) ;}int main () {while ( ~scanf ( "%d%d%d" , &n , &m , &k ) ) solve () ;return 0 ;}
0 0
- SGU 117. Counting 快速幂
- 【SGU】117. Counting 快速幂
- SGU 117Counting(快速幂)
- SGU 117 Counting(快速幂)
- [SGU]117. Counting
- Sgu 117. Counting
- SGU - 117 - Counting (快速幂取模!)
- SGU 117 Counting 数论
- sgu 117 Counting
- SGU 117 Counting
- sgu 197 Nice Patterns Strike Back 矩阵快速幂
- 117. Counting
- sgu 197 Nice Patterns Strike Back(构造矩阵快速幂)
- SGU
- SGU
- SGU
- SGU
- SGU
- uml系列(六)——行为图:活动&状态
- HDU 3157 Crazy Circuits(有源汇上下界最小流)
- 三角形(2*)
- Linux下C语言RPC(远程过程调用)编程实例
- Girls and Boys(最大独立集=节点数-最大匹配数)
- 【SGU】117. Counting 快速幂
- 最近计划2014年11月12日
- 算法
- 阶乘之和(贪心)
- HTML5学习笔记(三)
- 实验二:线性表实验——信管1133-09
- 【Allwinner ClassA20类库分析】3.ClassA20功能及结构
- Struts2 处理一个form多个submit
- 《javascript高级程序设计》读书笔记(四)引用类型