<cf>B. Magic Forest

本文介绍了一种特殊的三角形——异或三角形,并提供了一个算法来计算特定条件下这种三角形的数量。输入一个整数n,算法将遍历所有可能的三角形组合,通过异或操作筛选出符合条件的三角形。


time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Imp is in a magic forest, where xorangles grow (wut?)

A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.

Formally, for a given integer n you have to find the number of such triples (a, b, c), that:

  • 1 ≤ a ≤ b ≤ c ≤ n;
  • , where denotes the bitwise xor of integers x and y.
  • (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input

The only line contains a single integer n (1 ≤ n ≤ 2500).

Output

Print the number of xorangles of order n.

Examples
Input
6
Output
1
Input
10
Output
2
Note

The only xorangle in the first sample is (3, 5, 6).

异或三角形(应该这么叫吧 )....... >O(n^2)直接便利就好 数据2500而已

#include<iostream>
using namespace std;
typedef long long ll ;
#define f(i,l,r) for(int i=l;i<=r;++i)
#define g(i,l,r) for(int i=l;i>=r;--i)





int main(){
	int n ;
	int ans= 0;

	cin>>n;
	f(i,1,n)
		f(j,i+1,n){
			int m = i^j;   
			if(m>=1&& m <=n&&m>j&&i+m>j&&j+m>i&&i+j>m)
				ans++;
	}
	cout<<ans<<endl;
}


未来的我一定会感谢正在努力的现在的我!


<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>lab6</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-common</artifactId> <version>3.4.1</version> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-mapreduce-client-core</artifactId> <version>3.4.1</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.0.0</version> <configuration> <filters> <filter> <artifact>*:*</artifact> <!--重点:打包排除 *.SF *.DSA *.RSA 文件--> <excludes> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> hadoop@2899f21a8979:~$ hadoop jar lab6.jar data/wordfile1.txt data/wordfile2.txt output Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:325) at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:267) at java.util.jar.JarVerifier.processEntry(JarVerifier.java:332) at java.util.jar.JarVerifier.update(JarVerifier.java:242) at java.util.jar.JarFile.initializeVerifier(JarFile.java:402) at java.util.jar.JarFile.getInputStream(JarFile.java:480) at org.apache.hadoop.util.RunJar.unJar(RunJar.java:201) at org.apache.hadoop.util.RunJar.unJar(RunJar.java:105) at org.apache.hadoop.util.RunJar.run(RunJar.java:317) at org.apache.hadoop.util.RunJar.main(RunJar.java:245)
最新发布
11-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值