SGU---102 欧拉函数
题目链接:
https://cn.vjudge.net/problem/SGU-102#author=0
题目大意:
求解小于等于N的且与N互质的数字有多少个
解题思路:
直接求欧拉函数即可
关于欧拉函数的知识:传送门
这里可以直接暴力,但是如果不会欧拉函数单个求,打表求的话还是看上述链接。
#include<bits/stdc++.h>
using namespace std; int main()
{
int n, ans = ;
scanf("%d", &n);
for(int i = ; i <= n; i++)
if(__gcd(i, n) == )ans++;
printf("%d\n", ans);
return ;
}
SGU---102 欧拉函数的更多相关文章
- sgu 102模拟欧拉函数
感觉自己弱爆了,做做SGU吧... #include<iostream> #include<cmath> //欧拉函数 using namespace std; int eul ...
- UVA12493 - Stars(求1-N与N互质的个数)欧拉函数
Sample Input 3 4 5 18 36 360 2147483647 Sample Output 1 1 2 3 6 48 1073741823 题目链接:https://uva.onlin ...
- 快速切题 sgu102.Coprimes 欧拉函数 模板程度 难度:0
102. Coprimes time limit per test: 0.25 sec. memory limit per test: 4096 KB For given integer N (1&l ...
- hdu2588 GCD (欧拉函数)
GCD 题意:输入N,M(2<=N<=1000000000, 1<=M<=N), 设1<=X<=N,求使gcd(X,N)>=M的X的个数. (文末有题) 知 ...
- BZOJ 2705: [SDOI2012]Longge的问题 [欧拉函数]
2705: [SDOI2012]Longge的问题 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 2553 Solved: 1565[Submit][ ...
- BZOJ 2818: Gcd [欧拉函数 质数 线性筛]【学习笔记】
2818: Gcd Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 4436 Solved: 1957[Submit][Status][Discuss ...
- COGS2531. [HZOI 2016]函数的美 打表+欧拉函数
题目:http://cogs.pw/cogs/problem/problem.php?pid=2533 这道题考察打表观察规律. 发现对f的定义实际是递归式的 f(n,k) = f(0,f(n-1,k ...
- poj2478 Farey Sequence (欧拉函数)
Farey Sequence 题意:给定一个数n,求在[1,n]这个范围内两两互质的数的个数.(转化为给定一个数n,比n小且与n互质的数的个数) 知识点: 欧拉函数: 普通求法: int Euler( ...
- 51Nod-1136 欧拉函数
51Nod: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1136 1136 欧拉函数 基准时间限制:1 秒 空间限制: ...
- 欧拉函数 - HDU1286
欧拉函数的作用: 有[1,2.....n]这样一个集合,f(n)=这个集合中与n互质的元素的个数.欧拉函数描述了一些列与这个f(n)有关的一些性质,如下: 1.令p为一个素数,n = p ^ k,则 ...
随机推荐
- Angular的表单组件
创建表单元素 在上一节中,我们学习了如何创建一个组件login,现在将login改造一下, 在template中添加html表单元素,#usernameRef表示input元素id,如果想传递inpu ...
- Winfrom 基于TCP的Socket服务端 多线程(进阶版)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 鼓捣phantomjs,做ajax网站的信息采集
版权所有:http://www.cnblogs.com/zeusro/ 引用不给稿费的,切你jj 准备工作: 1phantomjs的安装 2 phantomjs环境变量的配置 需求: 采集手机淘宝某店 ...
- static dictionary methods of text compression
Now I will introduce a way to compress a text. When we are confronted with numerous data, and the da ...
- hdu 1828 Picture 切割线求周长
Picture Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- Nginx代理后服务端使用remote_addr获取真实IP
直奔主题,在代理服务器的Nginx配置(yourWebsite.conf)的location /中添加: #获取客户端IP proxy_set_header Host $host; proxy_set ...
- [js样式效果]具有停顿效果上下滚动方式
一般用于公告的滚动效果 <!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> ...
- (一)windows下安装MongoDB解压版
windows下安装MongoDB解压版 我安装的是(mongodb-win32-x86_64-2008plus-ssl-4.0.8.zip)版本 亲测可以使用. 连接: Windows下MongoD ...
- Android Fragment功能的例子
实现的功能很简单,也是最基本的,上下分别是两个Fragment,上面的Fragment中是一个listview,当点击item时,下面的Fragment显示对应的文字详细信息 具体的实现步骤如下:①创 ...
- Android 开发中三种多线程
在开发工程中线程可以帮助我们提高运行速度,Android开发中我知道的线程有四个一个是老生长谈的Thread,第二个是asyncTask,第三个:TimetTask,第四个是Looper,四个多线程各 ...