您的位置:首页 > 其它

暴力 hihoCoder 1178 计数

2015-06-15 10:33 495 查看
题目传送门

 /*
暴力:这题真是醉了,直接暴力竟然就可以了!复杂度不会分析,不敢写暴力程序。。
枚举x,在不重复的情况下+ans,超过范围直接break
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;

typedef long long ll;
const int MAXN = 1e7 + 10;
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) == 1)
{
if (n == 0)    break;
scanf ("%lld%lld", &L, &R);
memset (vis, false, sizeof (vis));

int ans = 0;
for (ll i=1; 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 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: