Content 一个序列由从 \(1\) 开始的数字不断在末端拼接,就像这样:\(12345678910111213141516...\).现在,给定一个数字 \(k\),请输出这个序列的第 \(k\) 个数字. 数据范围:\(1\leqslant k\leqslant 10000\). Solution 这题的数据范围不是很大,我们可以直接模拟得到长度为 \(10000\) 的序列,然后就可以直接输入输出了. Code int n = 1, cur, d[10007]; int main()…
一个简单的模拟,首先先计算当前是几位数,然后根据几位数推断当前的数是什么,然后求出该位即可 #include <cstdio> int main(){ long long k; scanf("%lld", &k); long long cur = 1, cnt = 9; while (cur * cnt < k){k -= cur * cnt; cnt *= 10, ++cur;} long long mod = k % cur, a = (k - 1) /…
http://codeforces.com/problemset/problem/1216/E1 E1. Numerical Sequence (easy version) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The only difference between the easy and the hard ver…
一.题目 D1. Submarine in the Rybinsk Sea (easy edition) 二.分析 简单版本的话,因为给定的a的长度都是定的,那么我们就无需去考虑其他的,只用计算ai的值在每个位置的贡献即可. 因为长度是定的,如果ai在前,那么对所有的a的贡献就是在偶数位的贡献值然后乘以n即可. 如果ai在后,那么对所有ai的贡献就是在奇数位的贡献值然后乘以n. 将两种情况合并,其实就是求ai在每个位置下的贡献,然后乘以n. 时间复杂度是$O(n)$ 三.AC代码 1 #incl…
The only difference between the easy and the hard versions is the maximum value of \(k\). You are given an infinite sequence of form "112123123412345-" which consist of blocks of all consecutive positive integers written one after another. The f…
http://poj.org/problem?id=2826 题目大意:给两条线,让它接竖直下的雨,问其能装多少横截面积的雨. ———————————————————————————— 水题,看题目即可知道. 但是细节是真的多……不过好在两次AC应该没算被坑的很惨(全程没查题解). 推荐交之前看一下讨论版的数据,方便一次AC(我第一次就是作死直接交了结果我自己都想好的情况忘了写了……) 相信看到这篇题解的人都看过题了,那么先说细节: 1.C++提交(G++不知道为什么WA了……) 2.精度 3.…
https://codeforc.es/contest/1195/problem/D1 给\(n\)个等长的十进制数串,定义操作\(f(x,y)\)的结果是"从\(y\)的末尾开始一个一个交替放得到的数",求\(\sum\limits_{i=1}^{n}\sum\limits_{j=1}^{n}f(a_i,a_j)\) 很明显每个第\(k\)位(从1开始)都会恰好在\(2k\)和\(2k-1\)位各贡献\(n\)次.预处理出\(pow10\)然后暴力就可以了. #include<…
题面: 传送门 题目描述: 要求用十字星星来画题目给出的"星"图.如果不能用十字星星来画"星"图,输出-1:如果能,则输出要在图的哪个位置画相应大小的十字星图.   题目分析: 这道题纯属模拟题,按照要求画就好了.我的画法:根据题目的"星"图用十字星图在另一个二维数组画"星"图.拿第一个样例来说:当遍历到第一颗星星,我就会检查是否能用十字星星去按题目给出的"星图"填充: 显然,第一个星星不能用十字星星去画图…
考虑在一个确定的括号序列中,我们可以枚举中间位置,按左右最长延伸出去的答案计算. 我们很自然的思考,我们直接维护左右两边,在删除一些字符后能够延伸的最长长度. 我们设\(f_{i,j}\)为\(i\)点合法删除向左延伸的最大长度. \( f_{i,j} = \left\{ \begin{aligned} &f_{i - 1,j} (a[i] = ')'\ )\\ &f_{i - 1,j - 1}(a[i] = ')'\ )\\ &f_{i - 1,j} + f_{i - 1 ,j…
Content 给定 \(n,m\),你需要输出一个长度为 \(n\) 的排列,满足该排列进行不超过 \(m\) 次交换操作可以得到的最小的字典序最大. 数据范围:\(T\) 组数据,\(1\leqslant T\leqslant 10^5\),\(1\leqslant n\leqslant 10^5\),\(\sum n\leqslant 10^5\),\(0\leqslant m\leqslant n\). Solution 算是一道比较小清新的构造题,接下来教你如何弄出正确的构造方案. 首…
A. Beautiful String (暴力) 题目链接 题目大意: 给定一个字符串,只有 \(?a\ b\ c\ ?\) ,问是否存在一种将所有的 \(?\) 替换成 \(a\ b\ c\) ,使得任意相邻的字符不同的方法. 大致思路: 其实可以发现问号都可以通过枚举使得其合法,若出现不合法必然除去问好已经不合法,暴力枚举即可. 代码: 点击展开代码 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; char…
Beautiful Sequence Beautiful Mirrors Beautiful Bracket Sequence (easy version) Beautiful Sequence \[ Time Limit: 1000 ms\quad Memory Limit: 256 MB \] 首先我们可以考虑到 \(0\) 只能 和 \(1\) 放在一起.\(3\) 只能和 \(2\) 放在一起,那么我们想办法先把 \(0\) 和 \(3\) 凑出来,最后就剩下 \(1\) 和 \(2\)…
又是隔了一年才来补题的我 A.B水题就不用说了 C - Yet Another Walking Robot C题我居然卡了一会,最后决定用map水,结果出来看了看题解,居然真的是map...没想到会出这样题解用stl的方法,是我失策了 #include <cstdio> #include <algorithm> #include <map> using namespace std; * ; char s[N]; typedef pair <int, int>…
感觉自己有点强迫症  不都写出来就找理由不写题解 http://codeforces.com/contest/1015   题目链接 A. Points in Segments 题目意思  n个线段 去覆盖1-m 中的点 问你没有覆盖的点的个数和位置 这个数据很小,可以直接暴力查找 思考:如果n<1e6, m<=1e8 呢? #include<bits/stdc++.h> #define int long long #define MAX(a,b,c) max(a,max(b,c)…
Java Algorithm Problems 程序员的一天 从开始这个Github已经有将近两年时间, 很高兴这个repo可以帮到有需要的人. 我一直认为, 知识本身是无价的, 因此每逢闲暇, 我就会来维护这个repo, 给刷题的朋友们一些我的想法和见解. 下面来简单介绍一下这个repo: README.md: 所有所做过的题目 ReviewPage.md: 所有题目的总结和归纳(不断完善中) KnowledgeHash2.md: 对所做过的知识点的一些笔记 SystemDesign.md:…
E1. Stars Drawing (Easy Edition) time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output A star is a figure of the following type: an asterisk character '*' in the center of the figure and four ra…
A - Points in Segments 题意:implement #include<bits/stdc++.h> using namespace std; typedef long long ll; bool vis[105]; int ans[105], atop; void test_case() { int n, m; scanf("%d%d", &n, &m); while(n--) { int u, v; scanf("%d%d&q…
Contest 81 (2018年11月8日,周四,凌晨) 链接:https://leetcode.com/contest/weekly-contest-81 比赛情况记录:结果:3/4, ranking: 440/2797.这次题目似乎比较简单,因为我比赛的时候前三题全做出来了(1:12:39),然后第四题有思路,正在写,没写完,比赛完了写完提交也对了. [821]Shortest Distance to a Character(第一题 4分) 给了一个单词(字符串)s,和单词中的任意一个字母…
A. Digits Sequence Dividing 注意特殊情况,在\(n = 2\)时除非\(str[1] >= str[2]\),否则可以把第一个数划分下来,剩下的数直接当成一组,一定满足条件. #include <cstdio> #include <iostream> #include <string> using namespace std; const int N = 310; int n; char s[N]; int main(){ int T;…
这个EASY难度的题怎么感觉比H的还难,昨天没做出来,今天才做出来.. 呃啊..我生 气 啦.. 直接看的答案,耻辱. 1 digit: 1~9 总共1×9个 2 digits: 10~99 总共2×90个 3 digits: 100~999 总共3×900个 .. ..... 所以就是先定位大区间,再从区间开始找确切位置.. public class Solution { public int findNthDigit(int n) { int digits = 1; long count =…
A. Digits Sequence Dividing 签. #include <bits/stdc++.h> using namespace std; #define N 1010 char s[N]; int n; void solve() { && s[] >= s[]) { puts("NO"); return; } else { puts("YES"); puts("); printf(], s + ); } }…
一.Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any sequence (ai1, ai2, ..., aiK), where 1 <= i1 < i2 < ... < iK <= N. For example, seq…
C. Mike and gcd problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if…
关于gitlab默认clone协议 Git实现从本地加入项目到远程仓库 翻翻git之---一个简单的标签控件 LabelView (随手发了两张小宝宝的玩耍照) id=1125" target="_blank" rel="nofollow" style="padding:0px; margin:0px; color:rgb(255,131,115); outline:0px; font-size:12px">Git 项目推荐 |…
A. Digits Sequence Dividing(英文速读) 练习英语速读的题,我还上来昏迷一次....只要长度大于2那么一定可以等于2那么前面大于后面就行其他no 大于2的时候分成前面1个剩下后面一定是对的因为按照数字大小 代码 #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n;…
目录 Contest Info Solutions A. Drinks Choosing B. Sport Mafia C. Basketball Exercise D1. Submarine in the Rybinsk Sea (easy edition) D2. Submarine in the Rybinsk Sea (hard edition) E. OpenStreetMap Contest Info Practice Link Solved A B C D1 D2 E F 6/7…
A. Drinks Choosing 有 $n$ 个人,每个人各有一种最喜欢的饮料,但是买饮料的时候只能同一种的两个两个买(两个一对) 学校只打算卖 $\left \lceil \frac{n}{2} \right \rceil$ 对 这意味着有些学生喝不到最喜欢的饮料,求最多有多少学生能喝的最喜欢的饮料 人数和饮料种数均小于等于 $1000$ 直接贪心,对于喜欢同一种饮料的学生中,如果人数为奇数,要么单独买一对,然后把另一个给不喜欢这种饮料的人 要么喝自己不喜欢的饮料,设喜欢某种饮料的学生人数…
题目链接:http://codeforces.com/contest/1163 A .Eating Soup sol:在n / 2.n - m.m三个数中取最小值,结果受这三个值限制.但是m == 0的情况需要特判 思维 #include "bits/stdc++.h" using namespace std; int main() { int n, m; scanf("%d%d", &n, &m); ) {puts(;} printf(, min(…
比赛链接:https://codeforces.com/contest/1440 A. Buy the String 题解 枚举字符串中 \(0\) 或 \(1\) 的个数即可. 代码 #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t--) { int n, c0, c1…