USACO Section 3.2: Stringsobits
这题看了网上的答案的。还是很巧妙的
/*
ID: yingzho1
LANG: C++
TASK: kimbits
*/
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <stdio.h>
#include <queue>
#include <cstring>
#include <cmath>
#include <list>
#include <cstdio>
#include <cstdlib>
using namespace std;
ifstream fin("kimbits.in");
ofstream fout("kimbits.out");
;
int N, L;
long long I;
int main()
{
fin >> N >> L >> I;
vector<vector<, vector<));
; i <= N; i++) f[i][] = ;
; i <= N; i++) {
; j <= i; j++) {
f[i][j] = f[i-][j-] + f[i-][j];
}
}
; i <= N; i++) {
; j <= N; j++) {
f[i][j] += f[i][j-];
}
}
; i--) {
][L] >= I) fout << ";
else {
fout << ";
I -= f[i-][L--];
}
}
fout << endl;
;
}
USACO Section 3.2: Stringsobits的更多相关文章
- USACO Section 3.2 01串 Stringsobits
题目背景 考虑排好序的N(N<=31)位二进制数. 题目描述 他们是排列好的,而且包含所有长度为N且这个二进制数中1的位数的个数小于等于L(L<=N)的数. 你的任务是输出第i(1< ...
- [USACO Section 3.2] 01串 Stringsobits (动态规划)
题目链接 Solution 贼有意思的 DP, 也可以用组合数学做. \(f[i][j]\) 代表前 \(i\) 位,有 \(j\) 个 \(1\) 的方案数. 转移方程很简单 : \(f[i][j] ...
- USACO Section 1.3 题解 (洛谷OJ P1209 P1444 P3650 P2693)
usaco ch1.4 sort(d , d + c, [](int a, int b) -> bool { return a > b; }); 生成与过滤 generator&& ...
- USACO Section 3.3: Riding the Fences
典型的找欧拉路径的题.先贴下USACO上找欧拉路径的法子: Pick a starting node and recurse on that node. At each step: If the no ...
- USACO Section 3.3 Camlot(BFS)
BFS.先算出棋盘上每个点到各个点knight需要的步数:然后枚举所有点,其中再枚举king是自己到的还是knight带它去的(假如是knight带它的,枚举king周围的2格(网上都这么说,似乎是个 ...
- [IOI1996] USACO Section 5.3 Network of Schools(强连通分量)
nocow上的题解很好. http://www.nocow.cn/index.php/USACO/schlnet 如何求强连通分量呢?对于此题,可以直接先用floyd,然后再判断. --------- ...
- USACO Section 5.3 Big Barn(dp)
USACO前面好像有类似的题目..dp(i,j)=min(dp(i+1,j),dp(i+1,j+1),dp(i,j+1))+1 (坐标(i,j)处无tree;有tree自然dp(i,j)=0) .d ...
- USACO Section 1.3 Prime Cryptarithm 解题报告
题目 题目描述 牛式的定义,我们首先需要看下面这个算式结构: * * * x * * ------- * * * <-- partial product 1 * * * <-- parti ...
- USACO Section 1.1 Your Ride Is Here 解题报告
题目 问题描述 将字符串转变为数字,字母A对应的值为1,依次对应,字母Z对应的值为26.现在有一个字符串,将其中的每个字符转变为数字之后进行累乘,最终的结果对47求余数. 题目给你两个字符串,其中的字 ...
随机推荐
- 利用 js 实现弹出蒙板(model)功能
关于 js 实现一个简单的蒙板功能(model) 思路: 创建一个蒙板, 设置蒙板的堆叠顺序保证能将其它元素盖住 position: absolute; top: 0; left: 0; displa ...
- ASP.NET MVC 如何在一个同步方法(非async)方法中等待async方法
问题 首先,在ASP.NET MVC 环境下对async返回的Task执行Wait()会导致线程死锁.例: public ActionResult Asv2() { //dead lock var t ...
- poj 1269 Intersecting Lines
题目链接:http://poj.org/problem?id=1269 题目大意:给出四个点的坐标x1,y1,x2,y2,x3,y3,x4,y4,前两个形成一条直线,后两个坐标形成一条直线.然后问你是 ...
- Noip2015总结
Noip2015战役总结 [游记部分] Day0 考前说是可以放松一下,下午呢就在机房打了几盘杀,一起玩了玩狼人.不过晚上觉得还是要有点氛围了,于是稍稍打了几个模板,觉得正确率还不错,给自己一点自信的 ...
- 【BZOJ】【1717】【USACO 2006 Dec】Milk Patterns产奶的模式
后缀数组 o(︶︿︶)o 唉傻逼了一下,忘了把后缀数组的字典范围改回20001,直接21交了上去,白白RE了两发……sigh 既然要找出现了K次的子串嘛,那当然要用后缀数组了>_>(因为我 ...
- 控制UIlabel 垂直方向对齐方式的 方法
最正统的方法,利用objective-c的category特性,修改UILabel的绘制代码.示例代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ...
- [geeksforgeeks] Convert a given Binary Tree to Doubly Linked List
http://www.geeksforgeeks.org/in-place-convert-a-given-binary-tree-to-doubly-linked-list/ Given a Bin ...
- unity资源(移动版)提取 一点尝试
原地址:http://blog.csdn.net/delguoqing/article/details/22619711 最近在参与一款手游,需要制定美术制作规范.因为拿不准主意,所以决定参考其他游戏 ...
- Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 8
Refer :http://www.cnblogs.com/mengfanrong/p/3745475.html Righ click on your project > properties ...
- Razor语法学习
原文:http://www.cnblogs.com/youring2/archive/2011/07/24/2115254.html 1.Razor的文件类型 Razor支持两种文件类型,分别是.cs ...