题意翻译

题目大意

给定一个正整数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. hdu 1002 A + B Problem II(大正整数相加)

    代码: #include<cstdio> #include<cstring> #define Min(a,b) ((a)<(b)?(a):(b)) using names ...

  2. Object类方法简介二

    在学了Object类前面的三个常用方法后,又遇到它的另外三个方法——clone().finalize().getClass(),这三个方法不经常使用,但因为在学习过程遇到了,就简单的对它们的使用做一个 ...

  3. 日积(Running)月累(ZSSURE):Task之Cancel、OpenAccess之Delete及fo-dicom之DeepCopy、

    题记: 最近看了一篇关于架构方面的良心长文你的架构是怎样一步步腐化的?,文中字字句句道出了诸多从业者.初创企业,以及BAT都会遇到的问题,细细品读后认为工作生活中的诸多情况皆如此,都会有一个体量由小到 ...

  4. luogu1072 Hankson的趣味题

    题目大意 给出数a0, a1, b0, b1,求满足gcd(a0, x)=a1, lcm(b0, x)=b1的x的个数 解法一 枚举b1的因数,看看是否满足上述条件. 怎样枚举因数 试除法.对于1~s ...

  5. hdoj--2255--奔小康赚大钱(KM算法模板)

    奔小康赚大钱 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  6. php mktime和strtotime

    本文章来给各位同学介绍一下利用php用strtotime或mktime指定日期数据(本周,上周,本月,上月,本季度)实例,希望对各位同学会有所帮助呀. strtotime定义和用法 strtotime ...

  7. Gym-101915B Ali and Wi-Fi 计算几何 求两圆交点

    题面 题意:给你n个圆,每个圆有一个权值,你可以选择一个点,可以获得覆盖这个点的圆中,权值最大的m个的权值,问最多权值是多少 题解:好像是叙利亚的题....我们画画图就知道,我们要找的就是圆与圆交的那 ...

  8. Aspose.Words进行Word替换(插入图片和水印)

    由于最近一直在忙着做着Word打印模板的一些工作,就整理一些Asponse.Words对Word文档进行操作的资料. using System; using System.Collections.Ge ...

  9. 移动端rem设置(部分安卓机型不兼容)

    (function(win) { var doc = win.document; var docEl = doc.documentElement; var tid; function refreshR ...

  10. jQuery操作DOM知识总结

    jquery操作DOM(节点) 1.创建元素 //$(htmlStr) //htmlStr:html格式的字符串 $("<span>这是一个span元素</span> ...