SGU117—Counting (快速幂取模)
来源:互联网 发布:淘宝色差问题怎么回复 编辑:程序博客网 时间:2024/06/14 09:04
117. Counting
time limit per test: 0.5 sec.
memory limit per test: 4096 KB
Find amount of numbers for given sequence of integer numbers such that after raising them to theM-th power they will be divided by K.
Input
Input consists of two lines. There are three integer numbers N, M, K (0<N, M, K<10001) on the first line. There are N positive integer numbers − given sequence (each number is not more than10001) − on the second line.
Output
Write answer for given task.
Sample Input
4 2 509 10 11 12
Sample Output
1
题目是说,样例的第一行为三个数n,m,k;然后第二行有n个数,求第二行中,每个数的m次方能被k整除的个数。——快速幂
//题目大意:给定n个数,问这n个数的m次幂有多少能够被K整除。#include<iostream>#include<string.h>#include<stdio.h>#include<ctype.h>#include<algorithm>#include<stack>#include<queue>#include<set>#include<math.h>#include<vector>#include<map>#include<deque>#include<list>using namespace std;int a[99999];int quick_pow(int n,int m,int k){ int result=1; while(m) { if(m&1) result=(result*n)%k; n=n*n%k; m>>=1; } return result%k;}int main(){ int n,m,k; while(scanf("%d%d%d",&n,&m,&k)!=EOF) { int count=0; for(int i=0;i<n;i++) { scanf("%d",&a[i]); if(quick_pow(a[i],m,k)==0) count++; } printf("%d\n",count); } return 0;}
- SGU117—Counting (快速幂取模)
- sgu117:Counting
- SGU117 Counting
- SGU117
- sgu117
- SGU - 117 - Counting (快速幂取模!)
- SGU 117 Counting(快速幂)
- SGU117 水题 Easy
- SGU 117Counting(快速幂)
- SGU 117. Counting 快速幂
- 【SGU】117. Counting 快速幂
- HDU2952——Counting Sheep(搜索)
- poj2386——Lake Counting(搜索)
- Educational Codeforces Round 33 E Counting Arrays(欧拉素筛+费马小定理+快速幂)
- uva11401(Triangle Counting)
- UVA11401(Triangle Counting)
- Lake Counting(DFS)
- Counting Squares(1264)
- 【UML 建模】UML建模语言入门 -- 用例视图详解 用例视图建模实战
- linux驱动开发面试
- 使用自动生成java文件和自动编译的动态代理模式
- 练习赛13.4.求后序遍历
- xp+ubuntu 格式化了ubuntu,出现grub rescue,U盘启动进不去
- SGU117—Counting (快速幂取模)
- java.lang.SecurityException: No permission to modify given thread
- poj1837(分组背包)
- KM模板
- 可拖拉的Table jquery 实现
- 简单模拟LinkedList
- 特征向量的归一化方法
- 推荐书
- Android WebView缓存机制详解