HDU 6124 Euler theorem
思路:找规律
a 余数 个数
1 0 1 2
2 0 2 2
3 0 1 3 3
4 0 1 4 3
5 0 1 2 5 4
6 0 1 2 6 4
7 0 1 2 3 7 5
8 0 1 2 3 8 5
。。。。。。
对于每个a,所有小于ceil(a/2)的自然数都是b的余数,再加上a本身
所以答案是ceil(a/2)+1
代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset((a),(b),sizeof(a); int main()
{
ios::sync_with_stdio(false);
cin.tie();
int t;
cin>>t;
while(t--)
{
int a;
cin>>a;
if(a&)a++;
cout<<a/+<<endl;
}
return ;
}
HDU 6124 Euler theorem的更多相关文章
- 数学--数论--HDU - 6124 Euler theorem (打表找规律)
HazelFan is given two positive integers a,b, and he wants to calculate amodb. But now he forgets the ...
- HDU 6124 17多校7 Euler theorem(简单思维题)
Problem Description HazelFan is given two positive integers a,b, and he wants to calculate amodb. Bu ...
- 【2017 Multi-University Training Contest - Team 7】 Euler theorem
[Link]:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1005&cid=765 [Description] 问你a ...
- hdu 2824The Euler function
题目链接 快速求出a到b之间所有数的欧拉函数. 一个一个求肯定是不行的, 我们知道欧拉函数的公式为phi(n) = n*(1-1/i1)*(1-1/i2).......i1, i2为素因子. 那么我们 ...
- 2017 beijing icpc A - Euler theorem
2017-09-22 21:59:43 writer:pprp HazelFan is given two positive integers a,ba,b, and he wants to calc ...
- B - Euler theorem 数学
直接打表找规律 HazelFan is given two positive integers a,ba,b, and he wants to calculate amodbamodb. But no ...
- 2017杭电多校第七场1005Euler theorem
Euler theorem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others) ...
- 2017 Multi-University Training Contest - Team 7
HDU6121 Build a tree 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6121 题目意思:一棵 n 个点的完全 k 叉树,结点标号从 ...
- HDU6124
Euler theorem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)T ...
随机推荐
- HashMap(JDK1.9)详解
一.HashMap的概念. 1.HashMap类的继承实现关系如下:因此HashMap的功能有:可序列化.可克隆等功能. 2.HashMap的数据结构:数组+链表+红黑树. 3.键值对的存储方案:第一 ...
- n的二进制中有几个1
实例十七:n的二进制中有几个1 方法:result=n & (n-1) n&(n-1)的目的使最低位的1不断翻转. 比如:n=108,其二进制表示为0110 1100,则n& ...
- 最近整理出了有关大数据,微服务,分布式,Java,Python,Web前端,产品运营,交互等1.7G的学习资料,有视频教程,源码,课件,工具,面试题等等。这里将珍藏多年的资源免费分享给各位小伙伴们
大数据,微服务,分布式,Java,Python,Web前端,产品运营,交互 领取方式在篇尾!!! 基础篇.互联网架构,高级程序员必备视频,Linux系统.JVM.大型分布式电商项目实战视频...... ...
- Linux服务器---本地yum
本地yum 本地yum可以实现各种包的快速安装,避免漫长的下载过程 1.找一个centos的安装包,将其挂载的系统中 [root@localhost ~]# mount –t iso9660 –loo ...
- 在thinkphp里面执行原生的sql语句
在thinkphp里面执行原生的sql语句 怎样在thinkphp里面执行原生的sql语句? $Model = new Model();//或者 $Model = D(); 或者 $Model = M ...
- 关于Spring中,定时任务执行两次的解决办法
原因:如果spring-quartz.xml文件,在Spring的配置文件spring-config.xml中被加载,那么定时任务会被Spring和SpringMVC扫描两次,所以会被执行两次. 解决 ...
- ELK+Kafka学习笔记之FileBeat日志合并配置输出到kafka集群
filebeat.prospectors: - type: log #日志输出类型 enabled: true ...
- troubleshooting-Kerberos 鉴权异常
ERROR transport.TSaslTransport: SASL negotiation failurejavax.security.sasl.SaslException: GSS initi ...
- tomcat热启动没问题, 访问项目报500解决办法
新建maven项目 添加热启动 启动访问项目报错 报错提示 解决办法 思路:包冲突 在pom.xml中添加servlet <dependency> <groupId>javax ...
- sql注入学习心得与sqlmap使用心得
做题是最好的老师 首先先来分享一下我用来练手的题目,实验吧中的简单的sql注入1,2,3 不得不说,sql注入真是一个神奇的东西,至少我以前看起来一点头绪都没有的题目能入手了 首先是简单的sql注入3 ...