BZOJ1662: [Usaco2006 Nov]Round Numbers
1662: [Usaco2006 Nov]Round Numbers
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 147 Solved: 84
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
Sample Output
输出解释:
2 10 1x0 + 1x1 ROUND
3 11 0x0 + 2x1 NOT round
4 100 2x0 + 1x1 ROUND
5 101 1x0 + 2x1 NOT round
6 110 1x0 + 2x1 NOT round
7 111 0x0 + 3x1 NOT round
8 1000 3x0 + 1x1 ROUND
9 1001 2x0 + 2x1 ROUND
10 1010 2x0 + 2x1 ROUND
11 1011 1x0 + 3x1 NOT round
12 1100 2x0 + 2x1 ROUND
HINT
Source
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 500+100
#define maxm 500+100
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define mod 1000000007
using namespace std;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
return x*f;
}
ll c[][],cc[][],s[],a[],l,r;
ll work(ll n)
{
a[]=;
while(n)a[++a[]]=n&,n>>=;
ll t=;
for1(i,a[]-)
{
int x=i;
if(x&)x=(x>>)+;else x>>=;
t+=cc[i-][x];
}
s[]=;s[]=;
for3(i,a[]-,)
{
if(a[i])
{
int x=s[]-s[]-+i-;
if(x<=)x=;
else if(x&)x=(x>>)+;
else x>>=;
t+=cc[i-][x];
}
s[a[i]]++;
}
if(s[]>=s[])t++;
t++;
return t;
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
cc[][]=c[][]=;
for1(i,)
{
c[i][]=c[i][i]=;
for1(j,i-)c[i][j]=c[i-][j]+c[i-][j-];
cc[i][i]=;
for3(j,i-,)cc[i][j]=cc[i][j+]+c[i][j];
}
l=read();r=read();
printf("%lld\n",work(r)-work(l-));
return ;
}
BZOJ1662: [Usaco2006 Nov]Round Numbers的更多相关文章
- bzoj1662: [Usaco2006 Nov]Round Numbers 圆环数
Description 正如你所知,奶牛们没有手指以至于不能玩“石头剪刀布”来任意地决定例如谁先挤奶的顺序.她们甚至也不能通过仍硬币的方式. 所以她们通过"round number" ...
- 【分块打表】bzoj1662 [Usaco2006 Nov]Round Numbers 圆环数
#include<cstdio> using namespace std; #define BN 380000 const int table[]={0,185815,378154,561 ...
- 【BZOJ1662】[Usaco2006 Nov]Round Numbers 圆环数 数位DP
[BZOJ1662][Usaco2006 Nov]Round Numbers 圆环数 Description 正如你所知,奶牛们没有手指以至于不能玩"石头剪刀布"来任意地决定例如谁 ...
- BZOJ_1662_[Usaco2006 Nov]Round Numbers 圆环数_数位DP
BZOJ_1662_[Usaco2006 Nov]Round Numbers 圆环数_数位DP Description 正如你所知,奶牛们没有手指以至于不能玩“石头剪刀布”来任意地决定例如谁先挤奶的顺 ...
- 【BZOJ】1662: [Usaco2006 Nov]Round Numbers 圆环数(数位dp)
http://www.lydsy.com/JudgeOnline/problem.php?id=1662 这道题折腾了我两天啊-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 果然 ...
- 牛客假日团队赛5 F 随机数 BZOJ 1662: [Usaco2006 Nov]Round Numbers 圆环数 (dfs记忆化搜索的数位DP)
链接:https://ac.nowcoder.com/acm/contest/984/F 来源:牛客网 随机数 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言6 ...
- [BZOJ1662][POJ3252]Round Numbers
[POJ3252]Round Numbers 试题描述 The cows, as you know, have no fingers or thumbs and thus are unable to ...
- 【BZOJ1725】[Usaco2006 Nov]Corn Fields牧场的安排 状压DP
[BZOJ1725][Usaco2006 Nov]Corn Fields牧场的安排 Description Farmer John新买了一块长方形的牧场,这块牧场被划分成M列N行(1<=M< ...
- POJ 3252 Round Numbers
组合数学...(每做一题都是这么艰难) Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7607 A ...
随机推荐
- HDU5126---stars (CDQ套CDQ套 树状数组)
题意:Q次操作,三维空间内 每个星星对应一个坐标,查询以(x1,y1,z1) (x2,y2,z2)为左下顶点 .右上顶点的立方体内的星星的个数. 注意Q的范围为50000,显然离散化之后用三维BIT会 ...
- 关于linux内存使用情况
从操作系统角度看: 系统物理内存7.5g 目前已使用7.4g(包含14m的buffer和1.6g的cache) 剩余可用内存128m 从应用程序角度看: 目前已使用5.8g 剩余可用内存1.7g(因为 ...
- (转)Maven实战(二)构建简单Maven项目
上一节讲了maven的安装和配置,这一节我们来学习一下创建一个简单的Maven项目 1. 用Maven 命令创建一个简单的Maven项目 在cmd中运行如下命令: mvn archetype:gene ...
- C语言排序算法复习
排序算法有很多种,这里在复习和分析的基础上,做一个自己的总结: 首先要知道有哪些排序算法,google一下,有云C语言7大经典排序算法(也有8大).主要包括冒泡排序,快速排序,选择排序,插入排序,希尔 ...
- 输入内容, 列出可选的项: QComboBox
#include "widget.h" #include "ui_widget.h" #include <QtGui/QCompleter> #in ...
- samba服务简介
1.1 Samba 概述Samba主要用于Windows和Linux之间的文件共享,也一样用于Linux和Linux之间的共享文件:不过对于Linux和Linux之间共享文件有更好的网络文件系统NFS ...
- RPM包查询
一.查询包是否安装 [root@localhost Packages]# rpm -q httpd ---> 查询已安装的包(命令包名) #选项: # -q 查 ...
- MacOS U盘安装
通过Mac上的App Store下载安装程序 插入U盘 启动终端 输入命令 sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/R ...
- django: db - many to many
本讲介绍数据库多对多关系,代码样例继前文使用. 一,在 blog/models.py 中创建对象: # Many-To-Many Example : Authors vs Books class Au ...
- CSS Hack是什么意思
CSS hack由于不同的浏览器,比如Internet Explorer 6,Internet Explorer 7,Mozilla Firefox等,对CSS的解析认识不一样,因此会导致生成的页面效 ...