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 ...
随机推荐
- linux系统安装 dig和nslookup命令
Fedora / Centos:1.yum install bind-utils Ubuntu: 1.sudo apt-get install dnsutils Debian: 1.2 apt-get ...
- excel 批量在一列数据添加单引号以及逗号
在A列后插入一列B1输入="'"&a1&"'," 然后向下填充 就ok 了 向下填充:选中上方连续单元格,鼠标放在选中区域右下角处(会显示“十” ...
- Junit4用法
序号 方法和描述 1 void assertEquals(boolean expected, boolean actual) 检查两个变量或者等式是否平衡 2 void assertTrue(bool ...
- python函数里面,一个*是可变参数的元祖,两个*是可变参数的字典
python的函数中,有时会有类似*args,**keys这样的参数,代表的是可变参数,一个*表示元祖,两个*表示字典,就是说这个函数可以接受任何类型的参数,都不会报错,有些函数为了提高可用性,会加这 ...
- java多线程----线程池源码分析
http://www.cnblogs.com/skywang12345/p/3509954.html 线程池示例 在分析线程池之前,先看一个简单的线程池示例. 1 import java.util.c ...
- spoj1825 Free tour II
题目链接 一道神奇的点分治 貌似有很多做法,我觉得BIT要好些一些(雾 要求经过黑点数<k就用BIT区间查询前缀 对于每个点用 BIT[0,k-经过黑点数]的最大值+路径长度 使用点分治做到O ...
- C/C++之全局、static对象/变量的初始化问题
关于全局.static对象/变量的初始化问题 1. 全局变量.static变量的初始化时机:main()函数执行之前(或者说main中第一个用户语句执行之前). 2. 初始化顺序. 1)全局对象.外部 ...
- MySQL数据库----存储引擎
什么是存储引擎? 存储引擎说白了就是如何存储数据.如何为存储的数据建立索引和如何更新.查询数据等技术的实现方法.因为在关系数据库中数据的存储是以表的形式存储的,所以存储引擎也可以称为表类型(即存储和操 ...
- python之路----面向对象中的内置函数
property属性 什么是特性property property是一种特殊的属性,访问它时会执行一段功能(函数)然后返回值 例一:BMI指数(bmi是计算而来的,但很明显它听起来像是一个属性而非方法 ...
- tomcat应用org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]异常的根本原因
早上,有个应用又挂了,客户端打开时报404,看进程是还在的.倒回第一次异常的地方,可见catalina.out中有如下信息: 08:46:56.646 [ContainerBackgroundProc ...