#1178 : 计数

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://hihocoder.com/problemset/problem/1178

Description

Rowdark是一个邪恶的魔法师。在他阅读大巫术师Lich的传记时,他发现一类黑魔法来召唤远古生物,鱼丸。

魔法n能召唤类型i鱼丸当且仅当i能够被表示为x xor n*x对于某个正整数x和固定的n。

Rowdark想知道类型为[L,R]之间的鱼丸有多少种能被魔法n召唤。

Input

输入第一行包含个整数n(1 ≤ n ≤ 107)。

第二行包含两个整数,L, R(0 ≤ L ≤ R ≤ 107)。

Output

一行一个整数表示答案。

Sample Input

2

1 10

Sample Output

3

HINT

只有3(1 xor 2), 5(3 xor 6), 6(2 xor 4), 9(7 xor 14), 10(6 xor 12)满足要求。

题意

题解:

正着想不会,那我们就逆着想就好了~

代码:

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 100001
#define mod 10007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** int a[];
int main()
{
int n=read();
int l=read(),r=read();
for(int i=;i<=;i++)
{
ll tmp=(ll)(i)^(1LL*i*n);
if(tmp>r||tmp<)
continue;
a[tmp]=;
}
int ans=;
for(int i=l;i<=r;i++)
if(a[i]==)
ans++;
cout<<ans<<endl;
}

hihocoder #1178 : 计数 暴力的更多相关文章

  1. 暴力 hihoCoder 1178 计数

    题目传送门 /* 暴力:这题真是醉了,直接暴力竟然就可以了!复杂度不会分析,不敢写暴力程序.. 枚举x,在不重复的情况下+ans,超过范围直接break */ #include <cstdio& ...

  2. hihocoder 1178 : 计数

    #1178 : 计数 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Rowdark是一个邪恶的魔法师.在他阅读大巫术师Lich的传记时,他发现一类黑魔法来召唤远古生物, ...

  3. ACM学习历程—Hihocoder 1178 计数(位运算 && set容器)(hihoCoder挑战赛12)

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB   描述 Rowdark是一个邪恶的魔法师.在他阅读大巫术师Lich的传记时,他发现一类黑魔法来召唤远古生物,鱼丸. 魔法n能召 ...

  4. BZOJ - 4066 KD树 范围计数 暴力重构

    题意:单点更新,大矩阵(\(n*n,n≤10^5\))求和 二维的KD树能使最坏情况不高于\(O(N\sqrt{N})\) 核心在于query时判断当前子树维护的区间是否有交集/当前子节点是否在块中, ...

  5. 【Foreign】朗格拉日计数 [暴力]

    朗格拉日计算 Time Limit: 10 Sec  Memory Limit: 128 MB Description Input Output 仅一行一个整数表示答案. Sample Input 5 ...

  6. HDU 5701 中位数计数 暴力

    老题了,附上黄学长链接一发,直接改改就AC了,http://hzwer.com/1216.html #include <cstdio> #include <iostream> ...

  7. 【luogu P3953 逛公园】 题解

    题目链接:https://www.luogu.org/problemnew/show/P3953 题外话:感觉2017年神题好多..这还不是最神的一道,真在考场上我也就写个最短路计数暴力了.现在在大佬 ...

  8. NOIP2017 【游记】

    一年过去,想起去年还是个傻b[今年也是],心里总是无限的感慨. 脑海里是日日夜夜在机房的身影,一题一题AC的激情 我等今年等了许久,虽然我是个蒟蒻,但我有梦想的憧憬 鲲鹏展翅翼向天,扶摇直上九万里. ...

  9. hihoCoder 1185 连通性·三(Tarjan缩点+暴力DFS)

    #1185 : 连通性·三 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 暑假到了!!小Hi和小Ho为了体验生活,来到了住在大草原的约翰家.今天一大早,约翰因为有事要出 ...

随机推荐

  1. Selenium启动本地firefox的profile

    ProfilesIni pi = new ProfilesIni();FirefoxProfile profile = pi.getProfile("default");WebDr ...

  2. TestNG中同一个类中执行多个test()方法如何配置testng.xml

    public class IndexInfo extends BaseTesting{ private IndexPage IndexPage1;// private AddEquipmentInfo ...

  3. Autodesk Stingray 游戏引擎

    Autodesk的游戏引擎质量够高的. http://v.youku.com/v_show/id_XMTMwMjc0MDIwMA==.html?qq-pf-to=pcqq.group http://v ...

  4. MVC的路由

    MVC的路由包括以下几部分 路由名称,路由URL,路由的初始值,路由的约束,路由的命名空间 routes.MapRoute( name: "Default", url: " ...

  5. [转]【eoeAndroid索引】史上最牛最全android开发知识汇总

    一.开发环境搭建 (已完成) 负责人:kris 状态:已完成 所整理标签为:搭建 SDK JDK NDK Eclipse ADT 模拟器 AVD 调试器(DEBUG) DDMS 测试 日志 Logca ...

  6. HW7.12

    import java.util.Scanner; public class Solution { public static void main(String[] args) { double[] ...

  7. 关于dom节点绑定滑动事件导致浏览器上下滑动失效解决方案--黄丕巧

    1.移动端开发往往需要添加一下自定义的左右滑动事件,但是添加了左右滑动事件之后就要阻止浏览器大默认事件,否则dom节点的滑动事件和浏览器本身的滑动会出现冲突,导致滑动的时候会出现消失瞬间再出现的效果 ...

  8. 什么是ADB

    ADB, Android Debug Bridge, 是一个client-server程序,可以用来和安卓设备交流 Client: 用来发送命令的,client运行在开发机器上(电脑cmd, adb ...

  9. esb异常20160322_1948

    异常1. Failed to find entry point for component, the following resolvers tried but failed: [ 2016-03-2 ...

  10. hdu 1045 Fire Net(最小覆盖点+构图(缩点))

    http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit:1000MS     Memory Limit:32768KB   ...