暴力 hihoCoder 1178 计数
2024-09-07 23:32:50
/*
暴力:这题真是醉了,直接暴力竟然就可以了!复杂度不会分析,不敢写暴力程序。。
枚举x,在不重复的情况下+ans,超过范围直接break
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std; typedef long long ll;
const int MAXN = 1e7 + ;
const int INF = 0x3f3f3f3f;
bool vis[MAXN]; int main(void) //hihoCoder 1178 计数
{
// freopen ("B.in", "r", stdin); ll n, L, R;
while (scanf ("%lld", &n) == )
{
if (n == ) break;
scanf ("%lld%lld", &L, &R);
memset (vis, false, sizeof (vis)); int ans = ;
for (ll i=; i<=5e7; ++i)
{
ll tmp = i ^ (n * i);
if (tmp >= L && tmp <= R) {if (!vis[tmp]) {vis[tmp] = true; ans++;}}
} printf ("%d\n", ans);
} return ;
}
最新文章
- javax.servlet.http.HttpServlet was not found
- Android Application 对象介绍
- Objective-C 和 C++中指针的格式和.方法 和内存分配
- Visual Studio 2013 各版本注册码
- Linux基础--用户和组管理
- Spring框架:Spring容器具体解释
- (转)C# WinForm中 获得当前鼠标所在控件 或 将窗体中鼠标所在控件名显示在窗体标题上
- 道格拉斯—普克(Douglas一Peukcer)节点抽稀算法
- BZOJ 3402: [Usaco2009 Open]Hide and Seek 捉迷藏(最短路)
- MySQL下载安装、基本配置、问题处理
- PHPStudy+PHPStorm下配置隐藏项目入口文件
- Invalid property &#39;url&#39; of bean class [com.mchange.v2.c3p0.ComboPooledDataSource]
- 【STM32H7教程】第6章 STM32H7工程模板建立(IAR8)
- handsontable的基础应用
- [Swift]LeetCode926. 将字符串翻转到单调递增 | Flip String to Monotone Increasing
- Redis事物
- SpringMVC中请求路径参数使用正则表达式
- 7.mongo python 库 pymongo的安装
- kafuka资料学习
- Java设计模式之八 ----- 责任链模式和命令模式