校赛 E 题 Cows and Primitive Roots
来源:互联网 发布:不需要域名的企业邮箱 编辑:程序博客网 时间:2024/05/18 20:11
题目链接
这是我从codeforce中找到的一道题:
就是模拟,要注意边计算边取mod,这样才不会爆int~~
#include<stdio.h>int n;int judge(int num){ int tmp=1,i; for(i=1;i<=n-2;i++){ tmp=tmp*num%n; //边乘边取mod if( (tmp-1)%n==0)break; } if(i<=n-2)return 0; if( (tmp*num-1)%n==0)return 1; else return 0;}int main(){ int t; while(scanf("%d",&n)!=EOF){ int times=0; for(int i=1;i<n;i++){ if(judge(i)==1)times++; } printf("%d\n",times); } }
- 校赛 E 题 Cows and Primitive Roots
- A. Cows and Primitive Roots
- Codeforces 284A Cows and Primitive Roots [模拟题]
- 284A. Cows and Primitive Roots
- Primitive roots
- 299-e-Bulls and Cows
- pku1284 Primitive Roots
- POJ1284 Primitive Roots
- POJ 1284 Primitive Roots
- poj - 1284 - Primitive Roots
- Poj 1284 Primitive Roots
- 【POJ 1284】Primitive Roots
- poj1284 Primitive Roots (数论)
- POJ 1284 primitive roots
- poj1284 Primitive Roots
- POJ 1284Primitive Roots
- POJ 1284 Primitive Roots
- POJ1284 Primitive Roots
- 无法打开类型库文件:“msxml.dll”: No such file or directory(win7)
- 2013 年4月14号校赛B题 进制转化问题
- POJ2001 Shortest Prefixes
- 2013 年校赛C题 小明的积木
- 阶乘模板
- 校赛 E 题 Cows and Primitive Roots
- 如何把梯形平分成两个面积相等的图形
- VMware的面试题
- 面试题目---小字节序、大字节序、程序判断 网络字节 主流机器字节序
- 如何判断堆栈是从上往下还是从下往上增长的
- 操作系统常见面试题总结
- 缓冲区溢出 面试题
- 经典算法研究系列:四、教你通透彻底理解:BFS和DFS优先搜索算法
- 深度优先搜索 广度优先搜索算法