题意翻译

题目大意

给定一个正整数nn ,求满足如下条件的三元组(a,b,c)(a,b,c) 的个数:

  • 1 \le a \le b \le c \le n1≤a≤b≤c≤n
  • a \space xor \space b \space xor \space c=0a xor b xor c=0
  • 存在一个边长分别为a,b,ca,b,c 的三角形。

输入格式

一行一个正整数n(1 \le n \le 2500)n(1≤n≤2500)

输出格式

输出满足题意的三元组个数。

感谢U3144 浮尘ii 提供的翻译

题目描述

Imp is in a magic forest, where xorangles grow (wut?)

A xorangle of order nn is such a non-degenerate triangle, that lengths of its sides are integers not exceeding nn , and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order nnto get out of the forest.

Formally, for a given integer nn you have to find the number of such triples (a,b,c)(a,b,c) , that:

  • 1<=a<=b<=c<=n1<=a<=b<=c<=n ;
  • , where  denotes the bitwise xor of integers xx and yy .
  • (a,b,c)(a,b,c) form a non-degenerate (with strictly positive area) triangle.

输入输出格式

输入格式:

The only line contains a single integer nn (1<=n<=2500)(1<=n<=2500) .

输出格式:

Print the number of xorangles of order nn .

输入输出样例

输入样例#1: 复制

6
输出样例#1: 复制

1
输入样例#2: 复制

10
输出样例#2: 复制

2

说明

The only xorangle in the first sample is (3,5,6)(3,5,6) .

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,ans;
int main(){
scanf("%d",&n);
for(int i=;i<=n;i++)
for(int j=i+;j<=n;j++){
int k=i^j;
if(k>n) continue;
if(i+j>k&&abs(i-j)<k&&i+k>j&&abs(i-k)<j&&j+k>i&&abs(j-k)<i) ans++;
}
cout<<ans/;
}

CF922B Magic Forest的更多相关文章

  1. Codeforces Round #461 (Div. 2) B. Magic Forest

    B. Magic Forest time limit per test 1 second memory limit per test 256 megabytes Problem Description ...

  2. codeforces 922 B. Magic Forest(枚举、位运算(异或))

    题目链接:点击打开链接 Imp is in a magic forest, where xorangles grow (wut?) A xorangle of order n is such a no ...

  3. Codeforces Round #461 (Div. 2)B-Magic Forest+位运算或优雅的暴力

    Magic Forest 题意:就是在1 ~ n中找三个值,满足三角形的要求,同时三个数的异或运算还要为0: , where  denotes the bitwise xor of integers  ...

  4. codeforces 461div.2

    A Cloning Toys standard input/output 1 s, 256 MB     B Magic Forest standard input/output 1 s, 256 M ...

  5. Codeforces Round #461 (Div. 2)

    A - Cloning Toys /* 题目大意:给出两种机器,一种能将一种原件copy出额外一种原件和一个附件, 另一种可以把一种附件copy出额外两种附件,给你一个原件, 问能否恰好变出题目要求数 ...

  6. Codeforces Round #461 (Div. 2) B C D

    题目链接:http://codeforces.com/contest/922 B. Magic Forest time limit per test 1 second memory limit per ...

  7. [Codeforces Round #461 (Div2)] 题解

    [比赛链接] http://codeforces.com/contest/922 [题解] Problem A. Cloning Toys          [算法] 当y = 0 ,   不可以 当 ...

  8. Random Forest Classification of Mushrooms

    There is a plethora of classification algorithms available to people who have a bit of coding experi ...

  9. HDU 3987 Harry Potter and the Forbidden Forest(边权放大法+最小割)

    Harry Potter and the Forbidden Forest Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65536/ ...

随机推荐

  1. Storm集群组件和编程模型

     Storm工作原理: Storm是一个开源的分布式实时计算系统,常被称为流式计算框架.什么是流式计算呢?通俗来讲,流式计算顾名思义:数据流源源不断的来,一边来,一边计算结果,再进入下一个流. 比 ...

  2. Sublime Text 2 SFTP UnicodeDecodeError错误!

    右键-->SFTP/FTP ->Sync Remote To Local {作者:半条虫(466814195)} 提示下面错误 An unexpected error occurred, ...

  3. nyoj--106--背包问题(贪心,水题)

    背包问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 现在有很多物品(它们是可以分割的),我们知道它们每个物品的单位重量的价值v和重量w(1<=v,w<= ...

  4. [luogu普及] ---P1032 字串变换

    目的 刷完100AC (最近很不舒服,写博客耗时啊 记录第一个字符串的题目 参考 https://www.luogu.org/blog/user20197/solution-p1032 代码 #inc ...

  5. 了解php数据转json格式与前端交互基础

    php数据转json格式与前端交互 ArryJson1.php <?php $test=array(); $word=array("我12","要43", ...

  6. Redis五种数据类型及应用场景

    MySql+Memcached架构的问题 实际MySQL是适合进行海量数据存储的,通过Memcached将热点数据加载到cache,加速访问,很多公司都曾经使用过这样的架构,但随着业务数据量的不断增加 ...

  7. vue项目中阻止浏览器返回上一页

    vue项目中在某个页面阻止浏览器返回上一页,适用移动端.PC端. 使用场景例如: 首页 与 A页面     来回跳转,那样点击浏览器返回时也会来回跳转,本想当页面在首页的时候就不再返回了,所以这个时候 ...

  8. zgb老师关于java集合的总结

    数组:存多个数据 操作不便集合(Collection ):存多个数据 管理多个数据 提供更为方便的操作Iterator:专门针对集合 进行迭代List:有序的 允许重复的元素ArrayList:底层数 ...

  9. ES6变量的解构赋值

    变量的解构赋值 1.数组的解构赋值 2.对象的解构赋值 3.字符串的解构赋值 4.数值和布尔值的解构赋值 5.函数参数的解构赋值 6.圆括号问题 7.用途 1.数组的解构赋值 ES6 允许写成下面这样 ...

  10. web拼图错误分析

    老师要求用web制作一个拼图游戏. 发现的问题:点击随机生成拼图的按钮后,打乱的图片会出现无法还原的情况. 发现过程:每次生成一个拼图后会测试它怎么拼回去,结果发现有时候拼不回去. 数学原理:如果两个 ...