sgu102 Coprimes】的更多相关文章

102. Coprimes time limit per test: 0.25 sec. memory limit per test: 4096 KB For given integer N (1<=N<=104) find amount of positive numbers not greater than N that coprime with N. Let us call two positive integers (say, A and B, for example) coprime…
102. Coprimes time limit per test: 0.25 sec. memory limit per test: 4096 KB For given integer N (1<=N<=104) find amount of positive numbers not greater than N that coprime with N. Let us call two positive integers (say, A and B, for example) coprime…
SGU 解题报告(持续更新中...Ctrl+A可看题目类型): SGU101.Domino(多米诺骨牌)------------★★★type:图 SGU102.Coprimes(互质的数) SGU103.TrafficLights(交通灯)---------★★type:图 SGU104.LittleShopofFlowers(小花店)---★type:DP SGU105.Div3(整除3) SGU106.TheEquation(方程)-------------★type:数论 SGU107.…
链接: http://vj.acmclub.cn/contest/view.action?cid=168#problem/B Coprimes 时限:250MS     内存:4096KB     64位IO格式:%I64d & %I64u 状态 练习 SGU 102 问题描述 For given integer N (1<=N<=104) find amount of positive numbers not greater than N that coprime with N. L…
题目链接: https://cn.vjudge.net/problem/SGU-102#author=0 题目大意: 求解小于等于N的且与N互质的数字有多少个 解题思路: 直接求欧拉函数即可 关于欧拉函数的知识:传送门 这里可以直接暴力,但是如果不会欧拉函数单个求,打表求的话还是看上述链接. #include<bits/stdc++.h> using namespace std; int main() { ; scanf("%d", &n); ; i <= n…
102. Coprimes time limit per test: 0.25 sec. memory limit per test: 4096 KB 题解: 求一个1-10000之间的数 N 的互质数个数.题目很简单,有两种方法: 1.复杂度是O(n^2),依次判断从1到N-1的数是否与N互质. ​2.复杂度是O(n),换一种想法,先求与N不互质的数的个数,然后用N减去即可.例如9,从2开始循环,3与9不互质,那么3的倍数也与9不互质,所以6也与9不互质.因为N很小,所以可以开一个数组a[10…
太水了, 我都不忍心发题解, 但毕竟是sgu上一道题, 我试试能不能一直这么写下去,就是求phi,上代码 #include <cstdio> #include <cstring> #include <cstdlib> #include <iostream> #include <algorithm> #include <cmath> #define N 10010 using namespace std; int get_phi(int…
题目大意:给你一个正整数N,求出来不超过N 的并且与N互质的正整数的个数. 就是一个大水题~~~ 代码: #include<stdio.h> #include<string.h> int GCD(int m, int n) { ) return m; return GCD(n, m%n); } int main() { ; scanf("%d", &N); ; i<=N; i++) { ) sum++; } printf("%d\n&qu…
SGU还是个不错的题库...但是貌似水题也挺多的..有些题想出解法但是不想写代码, 就写在这里吧...不排除是我想简单想错了, 假如哪位神犇哪天发现请告诉我.. 101.Domino(2015.12.16) 102.Coprimes 求φ(N). 1<=N<=10^4 按欧拉函数的公式直接算..O(N^0.5)(2015.12.16) #include<cstdio> #include<cstring> #include<algorithm> using n…
容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001  A+B Problem First AC: 2017-10-13       Latest Modification: 2018-02-28 #include<bits/stdc++.h> using namespace std; int a,b; int main() { cin>>a>>b; cout<<…