太水了, 我都不忍心发题解, 但毕竟是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)
{
int m = sqrt(n+0.5);
int ans = n;
for (int i = ; i <= m; ++i)
if (n % i == )
{
ans = ans / i * (i-);
while (n % i == ) n /= i;
}
if (n > ) ans = ans / n * (n-);
return ans;
} int main()
{
int n;
scanf("%d", &n);
printf("%d\n", get_phi(n));
}

sgu 102 Coprimes的更多相关文章

  1. sgu 102 Coprimes 解题报告及测试数据

    102. Coprimes time limit per test: 0.25 sec. memory limit per test: 4096 KB 题解: 求一个1-10000之间的数 N 的互质 ...

  2. Coprimes - SGU 102(求互质数,水)

    题目大意:给你一个正整数N,求出来不超过N 的并且与N互质的正整数的个数. 就是一个大水题~~~ 代码: #include<stdio.h> #include<string.h> ...

  3. sgu 102模拟欧拉函数

    感觉自己弱爆了,做做SGU吧... #include<iostream> #include<cmath> //欧拉函数 using namespace std; int eul ...

  4. SGU 102

    For given integer N (1<=N<=104) find amount of positive numbers not greater than N that coprim ...

  5. SGU 乱搞日志

    SGU 100 A+B :太神不会 SGU 101 Domino: 题目大意:有N张骨牌,两张骨牌有两面有0到6的数字,能相连当且仅当前后数字相同,问能否有将N张骨牌连接的方案?思路:裸的欧拉回路,注 ...

  6. (欧拉公式 很水) Coprimes -- sgu -- 1002

    链接: http://vj.acmclub.cn/contest/view.action?cid=168#problem/B Coprimes 时限:250MS     内存:4096KB     6 ...

  7. SGU题目总结

    SGU还是个不错的题库...但是貌似水题也挺多的..有些题想出解法但是不想写代码, 就写在这里吧...不排除是我想简单想错了, 假如哪位神犇哪天发现请告诉我.. 101.Domino(2015.12. ...

  8. sgu102 Coprimes

    102. Coprimes time limit per test: 0.25 sec. memory limit per test: 4096 KB For given integer N (1&l ...

  9. SGU刷题之路开启

    VJ小组:SGU---48h/题 每道做出的题目写成题解,将传送门更新在这里. SGU:101 - 200 SGU - 107 水题 解题报告 SGU - 105 找规律水题 解题报告 SGU - 1 ...

随机推荐

  1. Css基础-派生选择器

    如果要修改li strong 里面文字的颜色可以这样写样式 派生选择器: li strong { color:red; } 效果:

  2. cocos2d-x 开发时的注意点

    转自:http://cjhworld.blog.163.com/blog/static/20707803620132693629307/ 1.       按照Cocos2d的编程风格,尽量少用构造函 ...

  3. centos yum安装mysql

    查看有没有安装包 # yum list mysql 安装mysql客户端 # yum install mysql # yum list mysql-server 安装mysql 服务器端 # yum ...

  4. [Bootstrap] 5. Button and well

    Element Identification There are a number of classes in Bootstrap that help add prominence to a page ...

  5. iOS开发——总结篇&IOS开发基础知识

    IOS开发基础知识 1:Objective-C语法之动态类型(isKindOfClass, isMemberOfClass,id) 对象在运行时获取其类型的能力称为内省.内省可以有多种方法实现. 判断 ...

  6. hibernate uniqueResult方法

    假设查询返回多个值用list()方法 public void testQuery(){ Configuration config = new Configuration().configure(); ...

  7. Mysql导出表结构及表数据 mysqldump用法

    几个常用用例: 1.导出整个数据库 mysqldump -u 用户名 -p 数据库名 > 导出的文件名     mysqldump -u wcnc -p smgp_apps_wcnc >  ...

  8. Nginx重定向[Rewrite]配置 for wordpress & Discuz

    首先Apache的Rewite规则差别不是很大,但是Nginx的Rewrite规则比Apache的简单灵活多了Nginx可以用if进行条件匹配,语法规则类似Cif ($http_user_agent ...

  9. MySQL(7):数值类型

    1. 数值类型  

  10. iOS之SDWebImage的使用

    第一步,下载SDWebImage,导入工程.github托管地址https://github.com/rs/SDWebImage 第二步,在需要的地方导入头文件 1 #import "UII ...