【codeforces480E Parking Lot】教程文章相关的互联网学习教程文章

Codeforces Round #720 (Div. 2)【代码】

总算又能安心刷题了 A. Nastia and Nearly Good Numbers 题意: 给定A、B,要求找出三个数 x,y,z。满足条件: x + y = z其中有两个数只能整除A,有一个可以整除A*Bx,y,z 各不相同 思路: 显然,z是最大的,让z整除A*B就行了 。 那么令 x = A*(B-1) , y = A , z = A*B 就行了。 这个时候,可以发现,B不能等于1,同时当B等于2的时候,x 和 y 相等。那么可以令 x = 3A ,y = A ,z = 4A。 Code: #include <bits/stdc++.h> #defi...

Educational Codeforces Round 108 (Rated for Div. 2) C【代码】

#include <bits/stdc++.h> #define priority_queue < ll, std::vector<ll>, std::greater<ll> > mnheap; #define REP(i,a,b) for (auto i = a; i != b; i++) #define ll long long int #define vi vector<int> #define vll vector<ll> #define vvi vector < vi > #define all(c) c.begin(),c.end() #define rall(c) c.rbegin(),c.rend() #define eb emplace_back #define f first #define s second #define pb push_back using nam...

Codeforces Round #402 (Div. 2)【代码】【图】

Codeforces Round #402 (Div. 2) A.日常沙比提#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> usingnamespace std; inline int read(){char c=getchar();int x=0,f=1;while(c<‘0‘||c>‘9‘){if(c==‘-‘)f=-1; c=getchar();}while(c>=‘0‘&&c<=‘9‘){x=x*10+c-‘0‘; c=getchar();}return x*f; } int n,a[10],b[10],ans; int main(){//freopen("in","r",stdin);n=read();for(int...

Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) B. Strings Equalization【代码】

链接:https://codeforces.com/contest/1241/problem/B题意:You are given two strings of equal length s and t consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.During each operation you choose two adjacent characters in any string and assign the value of the first character to the value of the second or vice versa.For example, if s is "acbc" ...

【枚举】【贪心】 Codeforces Round #398 (Div. 2) B. The Queue【代码】

卡题意……妈的智障一个人的服务时间完整包含在整个工作时间以内。显然,如果有空档的时间,并且能再下班之前完结,那么直接输出即可,显然取最左侧的空档最优。如果没有的话,就要考虑“挤掉”某个人,就是在某个人之前1分钟到达,这样显然比较优。就这些情况都考虑上就得了。#include<cstdio> using namespace std; typedef long long ll; ll ts,tf,t,a[100010],b[100010],wait=10000000000000ll,ans; int n,num[100010],m; int ...

CodeForces - 437A . The Child and Homework 题解【代码】

点这里进原题 A. The Child and Homework题目大意 张三要做题,题目有ABCD四个选项,如果其最长的选项大于其他所有选项的长度的2倍或最短的选项小于其他所有选项的长度的1/2,那张三就选这个选项,如果不是就选 C。 这个张三就是逊啦!解析 我的思路是先遍历四个选项找出最大的最小的,再遍历一遍判断是否符合题目条件,值得注意的是如果最长最短都符合的话也是要选C的 。(可能是因为张三不知道蒙哪个了吧)AC CODE #include <iostr...

Codeforces Round #324 (Div. 2) (快速判断素数模板)【代码】【图】

蛋疼的比赛,当天忘了做了,做的模拟,太久没怎么做题了,然后C题这么简单的思路却一直卡到死,期间看了下D然后随便猜了下,暴力了下就过了。A.找一个能被t整除的n位数,那么除了<=10以外,其他都可以用长度为n的10或100,1000 。。。 来往上加几个数而得到#include <iostream> #include <stdio.h> #include <set> #include <algorithm> #include <string.h> usingnamespace std;int getwei(int x) {int sum=0;while(x){sum++;x=x/1...

Codeforces Round #105 (Div. 2) (ABCDE题解)【代码】

比赛链接:http://codeforces.com/contest/148比较简单的一场,最长的一题也才写了30行多一点A. Insomnia curetime limit per test:2 secondsmemory limit per test:256 megabytes?One dragon. Two dragon. Three dragon?, — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine.However, just counting dragons was boring as well, so she entertained herse...

Codeforces484 A. Bits【代码】

题目类型:位运算传送门:>Here<题意:求区间\([L,R]内二进制中1的个数最多的那个数,如果有多解输出最小解\)解题思路想了15min就一遍A了我们可以贪心地在\(L\)的基础上+1,从小的往大的加。根据二进制的性质,我们不可能把原来的1变成0,除非在更高位搞出一个新的1来。因为如果不在更高位搞出一个1,就肯定比\(L\)小了。而我们又不可能搞掉一个地位,去弄一个高位,因为这样不仅没有让1的个数增多,反而让数字更大了因此我们的最优...

Preparing for Merge Sort CodeForces - 847B【代码】

Ivan has an array consisting of n different integers. He decided to reorder all elements in increasing order. Ivan loves merge sort so he decided to represent his array with one or several increasing sequences which he then plans to merge into one sorted array.Ivan represent his array with increasing sequences with help of the following algorithm.While there is at least one unused number in array ...

Codeforces Round #428C【代码】

Journey题意:给一颗树,边权都为1,从1出发,求走到叶子节点的边权和的期望(每次往孩子遍历的等概率的)思路:从1出发dfs,每个点到下一个点的概率是当前节点的概率乘孩子节点的个数,也就是当前点的边数-1,到叶子节点后计算概率乘边权和然后相加就是了,1节点需要特殊处理一下AC代码:#include "iostream" #include "iomanip" #include "string.h" #include "stack" #include "queue" #include "string" #include "vector" #in...

Codeforces Round #418 (Div. 2) C. An impassioned circulation of affection(双指针)【代码】

题目链接:Codeforces Round #418 (Div. 2) C. An impassioned circulation of affection题意:给你一个字符串,有q个询问,每个询问一个x和一个字符 o。现在让你在原来的字符串上最多改变x个字符,问能构成最长的o子串的长度。题解:一共有26*1500种状态,对于每个状态用双指针滚一滚就行了。 1 #include<bits/stdc++.h>2#define F(i,a,b) for(int i=(a);i<=(b);++i)3usingnamespace std;4 5constint N=1507;6int ans[27][N],n,k,...

Educational Codeforces Round 78 题解【代码】

A题水题,但是我做麻烦了,因为我不知道字符串内部也可以排序,学到一招#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> usingnamespace std; constint N=1e5+10; constint inf=0x3f3f3f3f; int a[27],b[27]; int main(){int t;cin>>t;while(t--){string p;string s;cin>>p>>s;int i;int l1=s.size();int l2=p.size(); int flag=0;if(l1<l2){cout<<"NO"<<endl;continue;}for(i=0;i<l1...

Codeforces-840D - Destiny(主席树上二分,思维)【代码】【图】

题目大意: 给你一个序列,一些查询 每次查询区间[L,R]中出现次数大于T的最小的a[i]是多少 题目思路: 一眼主席树 但是这个题目在于如何用好这个条件 2?≤?k?≤?5 假设这个序列长度是1000,k=5 那么就是找出现次数大于200的,但是这样的数字最多有多少个呢? 很明显 不会超过k个 然后我查询一个区间的数字个数的和的时候,如果小于T,直接退出 然后继续搜下去(这里不会有k<=5的限制,会退出的很快) 这里因为要求最小值 所以每次...

CodeForces - 820【代码】

Mister B and Book ReadingCodeForces - 820A 题意:C,V0,V1,A,L。.总共有C页书,第一天以V0速度读,每天加A,但是不能超过V1,并且要从前一天的看到的当前页数的前L页开始读#include<iostream> #include<cstdio> #include<cstring> usingnamespace std; int c,v0,v1,a,l,ans; int main(){scanf("%d%d%d%d%d",&c,&v0,&v1,&a,&l);while(c>0){ans++;if(ans!=1)c+=l;c-=v0;v0=min(v0+a,v1);}printf("%d",ans);return0; }AC 模拟Mister B...