博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
暴力 hihoCoder 1178 计数
阅读量:6994 次
发布时间:2019-06-27

本文共 964 字,大约阅读时间需要 3 分钟。

 

1 /* 2     暴力:这题真是醉了,直接暴力竟然就可以了!复杂度不会分析,不敢写暴力程序。。 3             枚举x,在不重复的情况下+ans,超过范围直接break 4 */ 5 #include 
6 #include
7 #include
8 #include
9 using namespace std;10 11 typedef long long ll;12 const int MAXN = 1e7 + 10;13 const int INF = 0x3f3f3f3f;14 bool vis[MAXN];15 16 int main(void) //hihoCoder 1178 计数17 {18 // freopen ("B.in", "r", stdin);19 20 ll n, L, R;21 while (scanf ("%lld", &n) == 1)22 {23 if (n == 0) break;24 scanf ("%lld%lld", &L, &R);25 memset (vis, false, sizeof (vis));26 27 int ans = 0;28 for (ll i=1; i<=5e7; ++i)29 {30 ll tmp = i ^ (n * i);31 if (tmp >= L && tmp <= R) {
if (!vis[tmp]) {vis[tmp] = true; ans++;}}32 }33 34 printf ("%d\n", ans);35 }36 37 return 0;38 }

 

转载于:https://www.cnblogs.com/Running-Time/p/4576501.html

你可能感兴趣的文章