<cf>B. Magic Forest


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;
}


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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="com.test.bean.Goods,java.util.ArrayList" %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>购物车</title> <style type="text/css"> table{border-collapse:collapse;} td{border:1px solid black; text-align:center; } #deal{margin-left:200px} </style> </head> <body> <jsp:useBean id="cart" class="com.test.bean.Cart" scope="session"></jsp:useBean> <%if(cart==null||cart.getGoodslist().size()==0) out.println("购物车空空如也.....<a href='index.jsp'>返回商品首页</a>"); else{ ArrayList<Goods>goodslist=cart.getGoodslist(); %> <div> 当前购物车共有<%=cart.getGcount() %>件物品    <a href='index.jsp'>返回商品首页</a><br> <table><tr> <td>序号</td> <td>商品号</td> <td>商品名称</td> <td>价格</td> <td>数量</td> <td>小计</td> <td>描述</td></tr> <%for(int i=0;i<goodslist.size();i++){ Goods goods=goodslist.get(i); %> <tr> <td><%=i+1 %></td> <td><%=goods.getGid() %></td> <td><%=goods.getGname() %></td> <td><%= String.format("%.2f", goods.getGprice())%></td> <td><%=goods.getGcount() %></td> <td><%=String.format("%.2f", goods.getGprice()*goods.getGcount()) %></td> <td><a href="<%=request.getContextPath() %>/Servlet/DelCartServlet?gid=<%=goods.getGid() %>">删除</a></td></tr> <%}%> </table><br> <span>总计</span><%=String.format("%.2f",cart.getTotal())%>    <input type="button" id="deal" value="购买" /></input> </div> <%}%> <script type="text/javascript"> var dealbutton=document.getElementById("deal"); dealbutton.onclick=function(){ var cf=confirm("确定购买吗?"); if(cf==true){ window.location.href="Servlet/DealServlet"; } } </script> </body> </html> 修改删除功能,在购物车物品数量大于1的情况下点击“删除”时减少1个,等于1时删除此项商品;
最新发布
06-06

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值