【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;
}

最新文章

  1. js中属性节点的应用
  2. VS.PHP详细破解教程,用Visual Studio编写PHP代码插件PhpTools
  3. DataSet导出到Excel,并生成文件(C#实现,可合并行和列)
  4. BZOJ2694: Lcm
  5. 线程——委托InvokeRequired和Invoke
  6. cxGrid使用汇总1
  7. jQuery.Validate自定义规程的使用案例
  8. tcmalloc源码剖析的资料
  9. ThinkPHP3.2 生成二维码
  10. 【社交系统ThinkSNS+研发日记三】基于 Laravel Route 的 ThinkSNS+ Component
  11. 通过response设置响应体
  12. select模型
  13. 【BZOJ 3561】 DZY Loves Math VI
  14. java http post/get 服务端和客户端实现json传输
  15. Django—第三方引用
  16. FCC学习笔记(三)
  17. Python自动化运维工具-Fabric部署及使用总结
  18. 16 jmeter中的监听器以及测试结果分析
  19. bzoj千题计划145:bzoj3262: 陌上花开
  20. spring boot与spring mvc的区别

热门文章

  1. sklearn preprocessing 数据预处理(OneHotEncoder)
  2. Docker之基础篇
  3. Ubuntu 安装软件和centos 对比命令
  4. Android控件-单选按钮RadioButton
  5. Python(五) 包、模块、函数与变量作用域
  6. SQL server无法启动服务,提示“错误1069: 由于登录失败而无法启动服务”
  7. UVA And Then There Was One
  8. mkdi---创建目录。
  9. 【Henu ACM Round#18 D】Looksery Party
  10. cogs 1446. [Commando War,Uva 11729]突击战