漏写的数字

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint; int cmp(const void * x, const void * y) {
#define datatype int
datatype dx = *((datatype *)(x)), dy = *((datatype *)(y));
//x < y
return dx > dy ? : -;
#undef datatype
} char str[];
int s[]; int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
std::ios::sync_with_stdio(), cin.tie();
cin >> str;
bool f, f1;
int n = strlen(str);
for (int i = ; i < n; i++) s[i] = str[i] - '';
int ans;
f = true, f1 = false;
int b = s[];
int ptr = ;
while (ptr < n) {
b++;
if (b < ) {
if (s[ptr] == b) {
ptr++;
continue;
} else {
if (f1) {
f = false;
break;
} else {
f1 = true;
ans = b;
}
}
} else {
if (s[ptr] == b / && s[ptr + ] == b % ) {
ptr += ;
continue;
} else {
if (f1) {
f = false;
break;
} else {
f1 = true;
ans = b;
}
}
}
}
if (f && f1) {
cout << ans << endl;
return ;
}
f = true, f1 = false;
b = s[] * + s[];
ptr = ;
while (ptr < n) {
b++;
if (b < ) {
if (s[ptr] == b) {
ptr++;
continue;
} else {
if (f1) {
f = false;
break;
} else {
f1 = true;
ans = b;
ptr++;
}
}
} else {
if (s[ptr] == b / && s[ptr + ] == b % ) {
ptr += ;
continue;
} else {
if (f1) {
f = false;
break;
} else {
f1 = true;
ans = b;
}
}
}
}
if (f && f1) {
cout << ans << endl;
return ;
}
return ;
}

扁平化管理

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint; int cmp(const void * x, const void * y) {
#define datatype int
datatype dx = *((datatype *)(x)), dy = *((datatype *)(y));
//x < y
return dx > dy ? : -;
#undef datatype
} lint a[][];
const lint inf = 0x7FFFFFFFFFFFFFFF; int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
std::ios::sync_with_stdio(), cin.tie();
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
lint aaa = , tmp = ;
if (i < j - ) continue;
for (int k = ; k < j; k++) {
aaa *= (i - k + );
tmp += aaa;
if (tmp > 1e18) break;
}
if (tmp > 1e18) a[i][j] = inf;
else a[i][j] = tmp;
}
}
lint n, l;
cin >> n >> l;
bool f = false;
for (int i = ; i < ; i++) {
for (int j = ; j < min((lint), l + ); j++) {
if (a[i][j] >= n && !f) {
cout << i << endl;
f = true;
}
}
}
if (!f) {
if (l == ) cout << n - << endl;
else if (l == ) {
lint tmp = (lint)sqrt(n);
if (tmp * tmp + >= n) cout << tmp << endl;
else cout << tmp + << endl;
} else {
for (int i = ;; i++) {
if (i < l - ) continue;
lint aaa = , tmp = ;
for (int k = ; k < l; k++) {
aaa *= (i - k + );
tmp += aaa;
if (tmp > 1e18) break;
}
if (tmp > n) {
cout << i << endl;
break;
}
}
}
}
return ;
}

小球染色

动态规划:dp[i][j]表示决定了前i个的颜色,最后j个颜色相同的方法数。

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint; int cmp(const void * x, const void * y) {
#define datatype int
datatype dx = *((datatype *)(x)), dy = *((datatype *)(y));
//x < y
return dx > dy ? : -;
#undef datatype
} lint dp[][];
const int mod = ; int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
std::ios::sync_with_stdio(), cin.tie();
int n, m, k;
cin >> n >> m >> k;
memset(dp, , sizeof(dp));
dp[][] = m;
for (int i = ; i <= n; i++) {
for (int j = ; j < k; j++) {
dp[i + ][j + ] = (dp[i + ][j + ] + dp[i][j]) % mod;
dp[i + ][] = (dp[i + ][] + dp[i][j] * (m - )) % mod;
}
}
lint ans = ;
for (int i = ; i < k; i++) ans = (ans + dp[n][i]) % mod;
cout << ans << endl;
return ;
}

三角形面积和2

[Offer收割]编程练习赛38的更多相关文章

  1. HihoCoder1652 : 三角形面积和2([Offer收割]编程练习赛38)(几何)(不会几何,占位)

    描述 如下图所示,在X轴上方一共有N个三角形.这些三角形的底边与X轴重合,底边上两个顶点的坐标分别是(Li, 0)和(Ri, 0),底边的对顶点坐标是(Xi, Yi).其中Li ≤ Xi ≤ Ri 且 ...

  2. HihoCoder1651 : 小球染色([Offer收割]编程练习赛38)(DP的优化)

    描述 小Ho面前有N个小球排成了一排.每个小球可以被染成M种颜色之一. 为了增强视觉效果,小Ho希望不存在连续K个或者K个以上的小球颜色一样. 你能帮小Ho计算出一共有多少种不同的染色方法么? 例如N ...

  3. HihoCoder1650 : 扁平化管理([Offer收割]编程练习赛38)(二分)

    描述 小Hi的公司包括CEO在内一共有N名员工.这N名员工的上下级关系形成树形结构,CEO处于树根,普通员工处于叶子节点. 现在公司希望管理扁平化,要求树形结构中的层级不超过L层.此外,假设A是B的直 ...

  4. HihoCoder1649 : 漏写的数字([Offer收割]编程练习赛38)(模拟题)

    描述 小A今年刚上幼儿园,正在学习写100以内的数字.幼儿园的老师留了一项作业,要求小A从某个100以内的数X开始一直写到另一个100以内的数Y(Y - X > 1). 不过粗心的小A在作业中漏 ...

  5. hihocoder [Offer收割]编程练习赛4

    描述 最近天气炎热,小Ho天天宅在家里叫外卖.他常吃的一家餐馆一共有N道菜品,价格分别是A1, A2, ... AN元.并且如果消费总计满X元,还能享受优惠.小Ho是一个不薅羊毛不舒服斯基的人,他希望 ...

  6. hihocoder [Offer收割]编程练习赛61

    [Offer收割]编程练习赛61 A:最小排列 给定一个长度为m的序列b[1..m],再给定一个n,求一个字典序最小的1~n的排列A,使得b是A的子序列. 贪心即可,b是A的子序列,把不在b中的元素, ...

  7. [Offer收割]编程练习赛46

    [Offer收割]编程练习赛46赛后题解 A.AEIOU 分析

  8. [Offer收割]编程练习赛97

    链接 [https://hihocoder.com/contest/offers97/problems] 题意 题目1 : 放置矩形 时间限制:10000ms 单点时限:1000ms 内存限制:256 ...

  9. hihoCoder[Offer收割]编程练习赛1题目解析

    题目1 : 九宫 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描写叙述 小Hi近期在教邻居家的小朋友小学奥数.而近期正好讲述到了三阶幻方这个部分,三阶幻方指的是将1~9不反 ...

随机推荐

  1. webpack学习(六)—webpack+react+es6(第2篇)

    接上篇        webpack学习(五)—webpack+react+es6(第1篇) 本文做个简单的图片加文字的页面.其中,配置文件跟上篇一致.项目结构: index.html <!DO ...

  2. Day 23 类的继承,派生,组合,菱形继承,多态与多态性

    类的继承 继承是一种新建类的方式,新建的类称为子类,被继承的类称为父类 继承的特性是:子类会遗传父类的属性 继承是类与类之间的关系 为什么用继承 使用继承可以减少代码的冗余 对象的继承 python中 ...

  3. MATLAB图形界面设计(上)

    参考https://www.cnblogs.com/BlueMountain-HaggenDazs/p/4307777.html 一.图形句柄 1.定义 MATLAB在创建每一个图形对象时,都会给该对 ...

  4. eas设置时分秒

  5. 【剑指Offer】64、滑动窗口的最大值

      题目描述:   给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值.例如,如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3,那么一共存在6个滑动窗口,他们的最大值分别为{ ...

  6. 佛祖保佑 永无BUG ; 心外无法 法外无心

    登录linux命令行后出现的图形 复制图形代码到相应的文件中保存,重新登录即可出现. Usage: For Ubuntu: 12.04: Just copy the content from Budd ...

  7. 将RedHat的yum更换为CentOS的yum

    CentOS6.8 脚本: #安装yum所需的包已经下载到本地 #!/bin/bashrpm -qa | grep yum | xargs rpm -e --nodepsrm -rf /etc/yum ...

  8. Pycharm中Git、Github的简单使用和配置

    Pycharm中Git.Github的使用 PyCharm本身自带了git,稍微配置一下就可以很好的在图形界面下进行Python项目的版本控制 配置Git 在配置前先新建一个项目,当然也可以打开已有的 ...

  9. mysql优化sql语句

    mysql优化sql语句   常见误区   www.2cto.com   误区1:   count(1)和count(primary_key) 优于 count(*)   很多人为了统计记录条数,就使 ...

  10. 0929MySQL JOIN的算法

    http://www.cnblogs.com/starhu/p/6418842.html http://www.cnblogs.com/starhu/p/6418833.html http://www ...