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/ ...
随机推荐
- Palindrome Linked List 234
推断是否为回文链栈 时间复杂度为O(n) 空间复杂度为O(1) : 运用递归 保证空间复杂度为O(1): 时间复杂度为O(n): 注意定义了一个全局变量 flag = true 用此标记来标记是否在推 ...
- Makefile中怎样调用python和perl文件为自己提供须要的数据
Makefile中怎样调用python和perl文件为自己提供须要的数据,利用print函数对外输出数据 实例代码例如以下 perl.pl #!/usr/bin/perl print("he ...
- xcode打包测试
模拟器的内存cpu网络,都是电脑的.xcode可以查看. Xcode7之前是限制人,限制电脑,限制app,限制真机调试的. Xcode7之后,做真机测试只需要apple id即可,会自动生成证书. X ...
- c20---指向函数的指针
// // main.c // 指向函数的指针 #include <stdio.h> void test() { printf("哥被执行了\n"); } int ge ...
- Swift3.0 split函数切割字符串
我们先看函数的原型: public func split(separator: Self.Iterator.Element, maxSplits: Int = default, omittingEmp ...
- Bootstrap 模态框使用
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- 每条sql语句实际上都是一个事物(事物多种类型解读)
事务(数据库引擎) 事务是作为单个逻辑工作单元执行的一系列操作.一个逻辑工作单元必须有四个属性,称为原子性.一致性.隔离性和持久性 (ACID) 属性,只有这样才能成为一个事务.原子性事务必须是原子工 ...
- 【MFC】如何在mfc窗口程序中调用控制台
1.工程名为Zero,在CZeroDlg.cpp中加入头文件 #include “conio.h” : 2.在CZeroDlg::OnInitDialog() {…}函数中加入AllocConsole ...
- Google浏览器“无法添加来自此网站的应用、扩展程序和应用脚本”的解决办法
原文链接:https://blog.csdn.net/Fan_Weibin/article/details/80402790 解决方法如下: 在桌面找到Google Chrome图标→右击属性→在快捷 ...
- 前端web通过flask操作数据库-增删改查
后端python代码: #coding:utf8 from flask import Flask,request,render_template import pymysql as mysql imp ...