暴力 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; }
相关文章推荐
- DELL电脑问题
- ubuntu10.04加入到win2003域
- fedora安装
- [转载]dns和dc分离安装
- 技嘉主BIOS检测错误
- GRE写作高频题目真的有用么?
- IIS+asp+mysql2005实例
- 关于LFS
- 新年礼物——制作好了自己的LFS,哈哈~~
- ubuntu10.04 安装ralink rt2870
- ubuntu10.04 安装ralink rt2870
- 硬件raid和软件raid说明、设置及维护
- ubuntuserver10.04 安装LAMP:PHP及配置drupal
- Win10不是真的免费 免费是有条件限制
- ubuntu server 10.04 apache2:安装webalizer、awstats
- ubuntu server 10.04:apache1:安装ssl
- Fiddler 教程
- ubuntu server 10.04 :使用ssh 密钥登录服务器
- 相关认识
- [摘录] ubuntu server 10.04 安装dhcp服务器