【2017 Multi-University Training Contest - Team 7】 Euler theorem
2024-08-27 16:56:10
【Link】:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1005&cid=765
【Description】
问你a%b的结果有多少种.
b未知,可以为任意数字.
【Solution】
b=a+1,a,a-1,a-2….
分别对应了a%b==a,0,1,2,…
且当b = a/2时,a%b会出现重复..
找一下a为奇数和偶数的两种情况.
发现规律就是(a-1)/2 + 2;
【NumberOf WA】
0
【Reviw】
【Code】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x+1)
#define oi(x) printf("%d",x)
#define ol(x) printf("%lld",x)
#define oc putchar(' ')
#define os(x) printf(x)
#define all(x) x.begin(),x.end()
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;
int main(){
//Open();
//Close();
int T;
ri(T);
while (T--){
int a;
ri(a);
oi((a-1)/2 + 2);puts("");
}
return 0;
}
最新文章
- js中属性节点的应用
- VS.PHP详细破解教程,用Visual Studio编写PHP代码插件PhpTools
- DataSet导出到Excel,并生成文件(C#实现,可合并行和列)
- BZOJ2694: Lcm
- 线程——委托InvokeRequired和Invoke
- cxGrid使用汇总1
- jQuery.Validate自定义规程的使用案例
- tcmalloc源码剖析的资料
- ThinkPHP3.2 生成二维码
- 【社交系统ThinkSNS+研发日记三】基于 Laravel Route 的 ThinkSNS+ Component
- 通过response设置响应体
- select模型
- 【BZOJ 3561】 DZY Loves Math VI
- java http post/get 服务端和客户端实现json传输
- Django—第三方引用
- FCC学习笔记(三)
- Python自动化运维工具-Fabric部署及使用总结
- 16 jmeter中的监听器以及测试结果分析
- bzoj千题计划145:bzoj3262: 陌上花开
- spring boot与spring mvc的区别
热门文章
- sklearn preprocessing 数据预处理(OneHotEncoder)
- Docker之基础篇
- Ubuntu 安装软件和centos 对比命令
- Android控件-单选按钮RadioButton
- Python(五) 包、模块、函数与变量作用域
- SQL server无法启动服务,提示“错误1069: 由于登录失败而无法启动服务”
- UVA And Then There Was One
- mkdi---创建目录。
- 【Henu ACM Round#18 D】Looksery Party
- cogs 1446. [Commando War,Uva 11729]突击战