Hihocoder 计数
来源:互联网 发布:软件服务商 编辑:程序博客网 时间:2024/06/07 05:49
题目2 : 计数
时间限制:10000ms
单点时限:1000ms
内存限制:256MB
- 样例输入
21 10
- 样例输出
5
描述
Rowdark是一个邪恶的魔法师。在他阅读大巫术师Lich的传记时,他发现一类黑魔法来召唤远古生物,鱼丸。
魔法n能召唤类型i鱼丸当且仅当i能够被表示为x xor n*x对于某个正整数x和固定的n。
Rowdark想知道类型为[L,R]之间的鱼丸有多少种能被魔法n召唤。
输入
输入第一行包含个整数n(1 ≤ n ≤ 107)。
第二行包含两个整数,L, R(0 ≤ L ≤ R ≤ 107)。
输出
一行一个整数表示答案。
样例提示
只有3(1 xor 2), 5(3 xor 6), 6(2 xor 4), 9(7 xor 14), 10(6 xor 12)满足要求。
#include <iostream>#include <cstdio>#include <cstring>using namespace std;#define maxn 10000000 + 10int n, L, R;bool vis[maxn];int main(){ // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(~scanf("%d%d%d", &n, &L, &R)) { int ans = 0; memset(vis, 0, sizeof(vis)); for(int i=1; i<=10000000; i++) { long long j = (long long)i*n; long long tmp = i^j; if(tmp <= R) vis[tmp] = true; } for(int i=L; i<=R; i++) if(vis[i]) ans++; printf("%d\n", ans); } return 0;}
1 0
- Hihocoder 计数
- hihocoder #1476 : 矩形计数
- hihoCoder 1476 矩形计数 dp
- hihoCoder挑战赛12 计数 打表
- hihoCoder挑战赛B题——计数
- hihocoder:
- hihoCoder
- Hihocoder
- hihocoder
- hihocoder
- hihocoder
- hihocoder
- hihocoder
- HihoCoder
- HihoCoder
- HihoCoder
- HihoCoder
- HihoCoder
- C# WinForm捕获未处理的异常实例解析
- opencv调用笔记本摄像头程序
- LeetCode_44---Wildcard Matching
- Android studio 重置 DDMS面板布局
- 使用SNMP++开发电信设备网管之二:SNMP++库用法
- Hihocoder 计数
- FICO上线准备
- 登陆页面的验证js
- 使用注解来构造IoC容器
- 使用Bash Shell处理JSON文件
- stm32.cube(七)——arm-gcc.helloworld
- 凸优化问题
- percona-toolkit 性能相关工具
- 自制工具:CSV代码生成器:自动生成CSV文件对应的C++实体类和字段类型解析代码