Love you Ten thousand years------Earth’s rotation is a day that is the representative of a day I love you. True love, there is no limit and no defects. Earth’s revolution once a year, it is on behalf of my love you more than a year. Permanent horizon, and my heart will never change ……

We say that integer x, 0 < x < n,(n is a odd prime number) is a LovePoint-based-on n if and only if the set { (x i mod n) | 1 <= i <= n-1 } is equal to { 1, …, n-1 }. For example, the powers of 3 modulo 7 are 3, 2, 6, 4, 5, 1, and thus 3 is a LovePoint-based-on 7.
Now give you a integer n >= 3(n will not exceed 2 31).
We say the number of LovePoint-based-on n is the number of days the earth rotating.
Your task is to calculate the number of days someone loved you.
Input
Each line of the input contains an integer n. Input is terminated by the end-of-file.
Output
For each n, print a single number that gives the number of days someone loved you.
Sample Input
5
Sample Output
2

题意:一个x(0 < x < n,n是素数),如果集合{ (x i mod n) | 1 <= i <= n-1}等于集合{ 1, …, n-1 }我们叫x是n的一个爱点,现在给出一个n,让你求n有多少个爱点。
思路:根据原根的定义:g^φ§对p取模等于1我们可以得出g ^ i(1<=i<=φ§)都不同(在区间1~p-1上),当p是素数时φ( p)=p-1,所以我们看出这里的爱点就是原根,题目就时求原根的个数,这个我们有公式:φ( n-1)

AC代码:

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long LL;
int phi(int x){int ans = x;for(int i = 2; i*i <= x; i++){if(x % i == 0){ans = ans / i * (i-1);while(x % i == 0) x /= i;}}if(x > 1) ans = ans / x * (x-1);return ans;
}
int main()
{LL n;while(scanf("%lld",&n)!=EOF){LL t;t=phi(n-1);printf("%lld\n",t);}
}

额(⊙﹏⊙),一开始理解错题了,以为要求n的原根。。。。。

HDU - 2619 Love you Ten thousand years相关推荐

  1. HDU - 2619 Love you Ten thousand years【原根】

    Discription Love you Ten thousand years------Earth's rotation is a day that is the representative of ...

  2. Waiting ten thousand years for Love

    最后一道搜索题,关键是划分状态.分析这道题: 如果以(x,y)为状态,无法唯一确定状态.因为('.' Indicate the road that Yifenfei can walk on it, o ...

  3. Concurrent Ten Thousand Connections.

    C10K来自 Concurrent Ten Thousand Connections. C10K问题指的是:如何优化套接字服务器以使之能够同时处理大量的客户请求.优化套接字服务器需要考虑的因素有操作系 ...

  4. 【HDU 2619】Love you Ten thousand years

    1.题目链接.原根的一个性.当a的阶等于phi(m)的时候,说明a是m的一个原根.首先这里原根的存在性是不用判断的,因为奇素数一定存在原根.当a是原根时,a^0,a^1,a^2....a^(odr(a ...

  5. HDU 2653 (记忆化BFS搜索+优先队列)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2653 题目大意:迷宫中有普通点和陷阱.其中普通点可以走可以飞,但是陷阱只能飞.走耗时1,飞耗时2.但 ...

  6. HTML特殊字符编码对照表 —— (二)

    特殊字符集二 数学相关符号 描述 符号/显示 UNICODE HEX CODE HTML CODE HTML ENTITY CSS CODE Plus Sign + U+0002B + + + \00 ...

  7. HTML 常用特殊符号

    描述 符号/显示 UNICODE HEX CODE HTML CODE HTML ENTITY CSS CODE Left Arrow ← U+02190 ← ← ← \2190 Up Arrow ↑ ...

  8. html常用特殊符号

    描述 符号/显示 UNICODE HEX CODE HTML CODE HTML ENTITY CSS CODE Left Arrow ← U+02190 ← ← ← \2190 Up Arrow ↑ ...

  9. new115.com dz.html,网页HTML特殊字符编码对照表

    下面是编程圈 jb51.cc 通过网络收集整理的代码片段.编程圈小编现在分享给大家,也给大家做个参考. 在设计和开发网页时,需要用到一些特殊符号,比如:©,®,℃,¥,⅜ 等等,有些上网找半天不一定能 ...

最新文章

  1. 多语言互通:谷歌发布实体检索模型,涵盖超过100种语言和2000万个实体
  2. linux安装的时候网卡配置失败,Linux下安装网卡执行make install失败
  3. (转)写的非常好的一个WPF学习之路
  4. php抓取搜狗图片,动手抓取搜狗搜索引擎壁纸API接口
  5. 神经网络中Batch和Epoch之间的区别
  6. 田渊栋教你读paper的正确姿势
  7. HTML连接共享文件,怎么连接共享文件夹
  8. 如何将Mac中的备忘录内容导出为 PDF文档?
  9. ResultSet用法集锦
  10. steam新授权软件_「西米软件推荐」桌面乱七八糟的人,请认真看完
  11. 百度云 自然语言处理(Nlp)
  12. 刷脸支付为人们消费方式创始一个新纪元
  13. 在window10中怎样连接扫描仪,扫描证件
  14. r语言 rep(c(1 3) 4),不倒翁-R语言入门系列4-rep函数的用法
  15. matlab反双曲函数表达,matlab求反正切
  16. Medusa(美杜莎)--参数及常见命令
  17. JavaScript 【99乘法表】【案例】
  18. 嘉为科技出席2021腾讯云启产业生态年会,荣获“年度通用明星奖”
  19. python//网络嗅探器
  20. datagridview 显示红色叉_显示器促销日常数码店招首页装修PSD模板分层psd素材

热门文章

  1. 天津租用网站的服务器,天津怎么租服务器
  2. 【理财入门三】你必须理解的金融常识—黄金
  3. 中国人民大学与加拿大女王大学金融硕士引领你走出职场困境,勇往直前!
  4. uni-app框架+app端+ethers.js库+以太坊开发+常见错误
  5. “珞珈三号01星”首个卫星影像三维模型!——重建大师最新成果
  6. 区块链开发语言python_6种最常见的区块链编程语言
  7. python学习笔记之三——MakeHuman源码阅读
  8. 仙侠手游【一问多情/魔藏仙缘】最新整理Linux手工服务端+视频教程+GM授权后台+本地热新资源
  9. 【华人学者风采】俞勇 上海交通大学
  10. pyplot颜色大全