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 ...
随机推荐
- ACM2039_三角形三边关系
#include <iostream> using namespace std; int main(int argc, char* argv[]) { double a,b,c; int ...
- 常用的MIME类型(资源的媒体类型)
后缀名 MIME名称 *.3gpp audio/3gpp, video/3gpp *.ac3 audio/ac3 *.asf allpication/vnd.ms-asf *.au audio/bas ...
- [Flask]学习Flask第三天笔记总结
from flask import Flask,render_template,request from others import checkLogin app = Flask(__name__) ...
- H面试程序(10): 字符串包含问题
题目描述:判断第二个字符串中的元素是否都能在第一个字符串中找到: 注意:和字符串的字串的问题有所区别,如第一个字符串为 abcdefg,第二个字符串为 aaabc,第二个字串还是包含于第一个字符串 ...
- 【从零学习openCV】IOS7下的人脸检測
前言: 人脸检測与识别一直是计算机视觉领域一大热门研究方向,并且也从安全监控等工业级的应用扩展到了手机移动端的app,总之随着人脸识别技术获得突破,其应用前景和市场价值都是不可估量的,眼下在学习ope ...
- 实现C++模板类头文件和实现文件分离的方法
如何实现C++模板类头文件和实现文件分离,这个问题和编译器有关. 引用<<C++primer(第四版)>>里的观点:1)标准C++为编译模板代码定义了两种模型:“包含”模型和“ ...
- rhel Linux系统yum的配置
yum是一个很方便的linux系统软件管理工具,但是很多新手还是不会配置yum,下面详细的介绍下yum的配置方法,其实很简单. 1.首先确保系统ISO镜像已经成功挂载,可以用df -h命令查看.2.创 ...
- linux下登录出现-bash-3.2#解决办法
1:下载 安装 csh yum install csh 2:再切换即可
- Swift 循环、数组 字典的遍历
import Foundation // 数组声明 var arr = [String]() // 数组循环添加项 ...{ arr.append("Item \(index)") ...
- [转]Xcode的重构功能
Xcode提供了以下几个重构功能: Rename Extract Create Superclass Move Up Move Down Encapsulate 在菜单栏中的位置如下图: 在代码区里直 ...