CF922B Magic Forest
题意翻译
题目大意
给定一个正整数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 .
输入输出样例
说明
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的更多相关文章
- 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 ...
- codeforces 922 B. Magic Forest(枚举、位运算(异或))
题目链接:点击打开链接 Imp is in a magic forest, where xorangles grow (wut?) A xorangle of order n is such a no ...
- Codeforces Round #461 (Div. 2)B-Magic Forest+位运算或优雅的暴力
Magic Forest 题意:就是在1 ~ n中找三个值,满足三角形的要求,同时三个数的异或运算还要为0: , where denotes the bitwise xor of integers ...
- codeforces 461div.2
A Cloning Toys standard input/output 1 s, 256 MB B Magic Forest standard input/output 1 s, 256 M ...
- Codeforces Round #461 (Div. 2)
A - Cloning Toys /* 题目大意:给出两种机器,一种能将一种原件copy出额外一种原件和一个附件, 另一种可以把一种附件copy出额外两种附件,给你一个原件, 问能否恰好变出题目要求数 ...
- 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 ...
- [Codeforces Round #461 (Div2)] 题解
[比赛链接] http://codeforces.com/contest/922 [题解] Problem A. Cloning Toys [算法] 当y = 0 , 不可以 当 ...
- Random Forest Classification of Mushrooms
There is a plethora of classification algorithms available to people who have a bit of coding experi ...
- HDU 3987 Harry Potter and the Forbidden Forest(边权放大法+最小割)
Harry Potter and the Forbidden Forest Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 65536/ ...
随机推荐
- JavaScript高级特性之原型
JavaScript的原型 原型prototype属性仅仅适用于函数对象(这里的函数对象是自己为了理解更好定义的,普通对象是没有原型属性的) 1.研究函数原型: <script type=&qu ...
- Hexo简介
Hexo是什么 Hexo(中文官方网站)是一个快速, 简洁且高效的博客框架. 让上百个页面在几秒内瞬间完成渲染. Hexo支持Github Flavored Markdown的所有功能, 甚至可以整合 ...
- tflearn anaconda 安装过程记录
准备工作:gcc升级为4.8.2glibc升级为2.18 /opt/xxx/xxx/components/ficlient/bigdata_env 里加入:export LD_LIBRARY_PATH ...
- CodeForces 651C
Description Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg s ...
- ClassLoader.getResourceAsStream(name);获取配置文件的方法
ClassLoader.getResourceAsStream(name);路径问题 InputStream in = getClass().getResourceAsStream('/'+" ...
- springboot与mybatis集成
1)添加依赖 <!-- mybatis --> <dependency> <groupId>org.mybatis.spring.boot</groupId& ...
- ubuntu-设置分辨率
xrandr -s 1440x900 -r 60 前提是,分辨率选项中有对应的设置选项.
- NOIP 2014 T2 联合权值 DFS
背景 NOIP2014提高组第二题 描述 无向连通图G有n个点,n-1条边.点从1到n依次编号,编号为i的点的权值为Wi ,每条边的长度均为1.图上两点(u, v)的距离定义为u点到v点的最短距离.对 ...
- AtCoder Beginner Contest 054
1. A - One Card Poker 水题,直接输出大小. 2. B - Template Matching 暴力,每个位置枚举,比较. 3. C - One-stroke Path n的大小只 ...
- JavaScript数组和json的区别
<html> <head> <meta charset="utf-8"> <title>无标题文档</title> &l ...