hdu 2654 Be a hero
()Become A Hero
Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 295 Accepted Submission(s): 83
Dear Lemon,
It is my way of success. Please caculate the algorithm, and secret is behind the answer. The algorithm follows:
Int Answer(Int n)
{
.......Count = 0;
.......For (I = 1; I <= n; I++)
.......{
..............If (LCM(I, n) < n * I)
....................Count++;
.......}
.......Return Count;
}
The LCM(m, n) is the lowest common multiple of m and n.
It is easy for you, isn’t it.
Please hurry up!
ZTY
What a good chance to be a hero. Lemon can not wait any longer. Please help Lemon get the answer as soon as possible.
即求i<n中 i, n不互质的个数
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll euler(ll x)
{
ll res = x;
for(int i= ;i*i<=x ;i++)
{
if(x%i == )
{
res = res/i*(i-);
while(x%i==)
x/=i;
}
}
if(x>)
res = res/x*(x-);
return res;
} int main()
{
int t;
scanf("%d",&t);
while(t--)
{
ll n;
scanf("%I64d",&n);
printf("%I64d\n",n-euler(n));
}
return ;
}
hdu 2654 Be a hero的更多相关文章
- HDU 4901 The Romantic Hero
The Romantic Hero Time Limit: 3000MS Memory Limit: 131072KB 64bit IO Format: %I64d & %I64u D ...
- HDU 4901 The Romantic Hero (计数DP)
The Romantic Hero 题目链接: http://acm.hust.edu.cn/vjudge/contest/121349#problem/E Description There is ...
- HDU 4901 The Romantic Hero(二维dp)
题目大意:给你n个数字,然后分成两份,前边的一份里面的元素进行异或,后面的一份里面的元素进行与.分的时候依照给的先后数序取数,后面的里面的全部的元素的下标一定比前面的大.问你有多上种放元素的方法能够使 ...
- HDU 3251 Being a Hero(最小割+输出割边)
Problem DescriptionYou are the hero who saved your country. As promised, the king will give you some ...
- HDU 4901 The Romantic Hero 题解——S.B.S.
The Romantic Hero Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Othe ...
- hdu 2654(欧拉函数)
Become A Hero Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- 2014多校第四场1005 || HDU 4901 The Romantic Hero (DP)
题目链接 题意 :给你一个数列,让你从中挑选一些数组成集合S,挑另外一些数组成集合T,要求是S中的每一个数在原序列中的下标要小于T中每一个数在原序列中下标.S中所有数按位异或后的值要与T中所有的数按位 ...
- hdu 4901 The Romantic Hero (dp)
题目链接 题意:给一个数组a,从中选择一些元素,构成两个数组s, t,使s数组里的所有元素异或 等于 t数组里的所有元素 位于,求有多少种构成方式.要求s数组里 的所有的元素的下标 小于 t数组里的所 ...
- HDU - 4901 The Romantic Hero(dp)
https://vjudge.net/problem/HDU-4901 题意 给n个数,构造两个集合,使第一个集合的异或和等于第二个集合的相与和,且要求第一个集合的元素下标都小于第二个集合的元素下标. ...
随机推荐
- TreeView的绑定与读取
/// <summary> /// 绑定TreeView /// </summary> public void BindTreeVie ...
- Yii2验证登录得User类
Yii2中的 Class yii\web\User 是如果进行验证登录,如果我们使用User类验证登录会给我们减少很多麻烦.在此就拿Yii2中自带的登录功能进行说明. 配置.在应用配置文件compo ...
- Flask解决跨域
Flask解决跨域 问题:网页上(client)有一个ajax请求,Flask sever是直接返回 jsonify. 然后ajax就报错:No 'Access-Control-Allow-Origi ...
- html页面源代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- C++语法知识小结(持续更新中)
1)在适用构造函数创建对象时,有时会创建临时对象.如 Stock::Stock(const std::string & co,long n,double pr); 在使用时,下面两条语句有根本 ...
- 转:[web]javascript 增加表單的input
利用javascript增加form的input 這是js的部份 //用來區分不同input的name var element_count = 0; function add_element(obj) ...
- 微信小程序HTTPS - cenos apache 下安装SSL证书
1.yum install mod_ssl 2.接下来,我们需要创建一个新目录,我们将存储服务器密钥和证书 mkdir /root/ssl 3.vi /etc/httpd/conf.d/ssl.con ...
- 【spring源码】bean的实例化(转载)
首先来看一段代码,看过上一节的朋友肯定对这段代码并不陌生.这一段代码诠释了Spring加载bean的完整过程,包括读取配置文件,扫描包,加载类,实例化bean,注入bean属性依赖. 上一节介绍了Sp ...
- 1. C/C++笔试面试经典题目一
1. 不用循环和递归,实现打印数字0到999. #include <iostream> #include<stdio.h> using namespace std; #defi ...
- MyBatis配置文件的配置说明
Properties 1.创建一个资源文件jdbc.properties: jdbc.driverClassName=oracle.jdbc.driver.OracleDriver jdbc.url= ...