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/ ...
随机推荐
- 分布式设计《初尝memcached》
之前听说过高性能的分布式缓存开源工具,但一直没有真正接触过,如今接触的产品中实用到过分布式缓存.所以决定一探到底.memcached是一个优秀的开源的分布式缓存工具.也是眼下比較火热的分布 ...
- (hdu step 7.1.7)Wall(求凸包的周长——求将全部点围起来的最小凸多边形的周长)
题目: Wall Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Subm ...
- vs2015编译使用GRPC
1.获取源码:位于github上 电脑装有git的直接克隆,未装git下载压缩包也可以 git clone https://github.com/grpc/grpc.git cd grpc git ...
- 微阅读,不依赖playground,打包成H5版本--案例学习
微阅读,不依赖playground,打包成H5版本 https://github.com/vczero/weex-yy-h5
- js 数组包含
function(arr,element){ return new RegExp('(^|,)'+element.toString()+'(,|$)').test(arr.toString()); }
- php获取前天的昨天的日期
在PHP里得到前天和昨天的日期的代码前天去面试的时候也是这样,不过我当时记不起来了.就记得MYSQL里面的date_sub(now(),'interval 1 day');date('Y/m/d h: ...
- 移动测试基础—adb、monkey命令
最近打算把移动测试相关的知识总结一下,先从基础开始吧,总结一下adb.monkey命令 adb常用命令总结 adb / adb -help 使用帮助 adb devices 查看连接到电脑的设备 ad ...
- Python基础教程思维导图笔记
说明:直接查看图片可能不太清楚,用浏览器打开后,按住 Ctrl ,网上滚动鼠标放大浏览器页面,可以看清楚图片
- 让break跳出外层循环的方法
demo //在里层循环里面,想办法让外层循环的条件不成立,就可以控制外层循环结束. for(var i = 0 ; i < 10; i++){ alert(i) for(var j = 0 ; ...
- MySQL 5.6 Reference Manual-14.6 InnoDB Table Management
14.6 InnoDB Table Management 14.6.1 Creating InnoDB Tables 14.6.2 Moving or Copying InnoDB Tables to ...