题意翻译

题目大意

给定一个正整数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. 关于android中线程,进程,组件,app的理解

    android系统是一座房子.有一个正常执行的公司进驻这所座子 cpu是这家公司的老板 进程是公司中的办公室,办公室不干活 线程是办公室中的员工,干活的永远是员工 一间办公室中可有多个员工,而且办公室 ...

  2. POJ2576 Tug of War 二维背包

    题目大意 一群人拔河,给出每个人的重量,要求两队人数之差不超过1人,且每队总重量之差最小. 思路 选出严格总人数一半(或+1)的人为一队,在该队重量不超过所有人总重量一半的情况下,使其重量最大. 人数 ...

  3. C++字符串与指针 所有的内容也就这么多了。

    1.定义一个字符串数组并初始化,然后输出其中的字符串. #include <iostream> using namespace std;int main(){ char str[]=&qu ...

  4. [Javascript] 5个最佳的Javascript日期处理类库

    在大家日常网站开发和web应用开发中,我们往往需要有效的调用Javascript处理日期和时间格式相关的函数,在Javascript中已经包含了部分最基本的内建处理方法. 在大家日常网站开发和web应 ...

  5. 数组和String调用方法时,值是否改变(包含可变参数)

    package com.wh.encapsulation; import java.util.Arrays; /** * @author 王恒 * @datetime 2017年4月5日 上午9:33 ...

  6. Android横屏时软键盘全屏问题

    1.使用 SearchView xml加入 android:imeOptions="actionDone|flagNoExtractUi" 可以限制软键盘禁止全屏 <andr ...

  7. junit使用第一弹

    知识点——断言 断言是编写测试用例的核心实现方式,即期望值是多少,测试的结果是多少,以此来判断测试是否通过. 1. 断言核心方法 assertArrayEquals(expecteds, actual ...

  8. otool -l 可执行文件结构

    otool -l /Users/zzf073/Desktop/FqlMerchantX /Users/zzf073/Desktop/FqlMerchantX: Mach header magic cp ...

  9. Spring依赖注入:@Autowired,@Resource和@Inject区别与实现原理

    一.spring依赖注入使用方式 @Autowired是spring框架提供的实现依赖注入的注解,主要支持在set方法,field,构造函数中完成bean注入,注入方式为通过类型查找bean,即byT ...

  10. Python基础:使用list & tuple

    list Python内置的一种数据类型是列表:list.list是一种有序的集合,可以随时添加和删除其中的元素. tuple 小结 list和tuple是Python内置的有序集合,一个可变,一个不 ...