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的更多相关文章

  1. 数学--数论--HDU - 6124 Euler theorem (打表找规律)

    HazelFan is given two positive integers a,b, and he wants to calculate amodb. But now he forgets the ...

  2. HDU 6124 17多校7 Euler theorem(简单思维题)

    Problem Description HazelFan is given two positive integers a,b, and he wants to calculate amodb. Bu ...

  3. 【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 ...

  4. hdu 2824The Euler function

    题目链接 快速求出a到b之间所有数的欧拉函数. 一个一个求肯定是不行的, 我们知道欧拉函数的公式为phi(n) = n*(1-1/i1)*(1-1/i2).......i1, i2为素因子. 那么我们 ...

  5. 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 ...

  6. B - Euler theorem 数学

    直接打表找规律 HazelFan is given two positive integers a,ba,b, and he wants to calculate amodbamodb. But no ...

  7. 2017杭电多校第七场1005Euler theorem

    Euler theorem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) ...

  8. 2017 Multi-University Training Contest - Team 7

    HDU6121 Build a tree 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6121 题目意思:一棵 n 个点的完全 k 叉树,结点标号从 ...

  9. HDU6124

    Euler theorem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)T ...

随机推荐

  1. sql中 substring和charindex 的用法

    -- 第一个参数是要截取的字符串,第二个参数是从第几个字符开始截取,第三个参数是截取的长度 --例如:select SUBSTRING('12345678',1,4) 返回 1234 -- selec ...

  2. js判断两个日期是否严格相差整年(合同日期常用)

    1.var beginDate = new Date($("#InvoiceStartTime").val()); var endDate = new Date($("# ...

  3. mysql进程文件

  4. cc150 --链表中倒数第k个节点

    题目描述 输入一个链表,输出该链表中倒数第k个结点.   快指针先走K步,然后快慢同时走,快走到末尾时,慢指针就是倒数第个.     public class Solution { public Li ...

  5. 174. Dungeon Game(动态规划)

    The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...

  6. Filter过滤器原理和登录实现

    Filter过滤器API      Servlet过滤器API包含了3个接口,它们都在javax.servlet包中,分别是Filter接口.FilterChain接口和FilterConfig接口. ...

  7. excel第一次打开报错 向程序发送命令时出错 多种解决办法含终极解决方法

    excel第一次打开报错 向程序发送命令时出错 多种解决办法含终极解决方法 office2007应该遇到“向程序发送命令时出现 问题”,设置为以管理员运行也不好用,重装office也不好用,下面介绍下 ...

  8. linux服务器上nginx日志访问量统计命令

    linux服务器上nginx日志访问量统计命令 日志文件所在地方:/var/log/nginx/access_iqueendress.com.log/var/log/nginx/access_m.iq ...

  9. Jquery图片上传组件,支持多文件上传

    Jquery图片上传组件,支持多文件上传http://www.jq22.com/jquery-info230jQuery File Upload 是一个Jquery图片上传组件,支持多文件上传.取消. ...

  10. mysql日志文件目录

    默认情况下mysql的二进制日志文件保存在默认的数据目录data下,如:/usr/local/mysql/data 修改日志保存目录(/backup/mysqlbinlog/mysql-bin)的话: ...