rated

CF1288(A,B,C)Round 80 (Rated for Div.2)

那年仲夏 提交于 2020-01-16 05:14:17
题目链接:https://codeforces.com/contest/1288 A. Deadline 题意 :给你n,d两个数,是否满足min(n , x + [ d / ( x + 1 ) ] ) <=d,(其中0<x<n,而⌈2.4⌉=3 , ⌈2⌉=2),如果满足输出YES,否则输出NO。 思路 :其实这个题中只要n/2和n/2+1满足条件即可。 AC代码 : # include <bits/stdc++.h> using namespace std ; typedef long long ll ; const int INF = 0x3f3f3f3f ; const int MAXN = 2e5 + 5 ; bool cheak ( int d , int x , int n ) { double tmp = d / ( x * 1.0 ) ; if ( tmp != d / x ) tmp = d / x + 1 ; if ( x - 1 + tmp <= n ) return 1 ; else return 0 ; } int main ( ) { ios :: sync_with_stdio ( 0 ) ; cin . tie ( 0 ) ; cout . tie ( 0 ) ; int t ; cin >> t ; while ( t -- ) { int n

Educational Codeforces Round 76 (Rated for Div. 2) - D. Yet Another Monster Killing Problem(贪心)

不问归期 提交于 2020-01-16 04:36:17
题意:有$n$个怪物,每个怪物有一个能力值$a[i]$,你现在有$m$个英雄,每个英雄有两个属性:$p[i]$表示这个英雄的能力值,$s[i]$表示这个英雄的耐力值,即一天内最多能消灭$s[i]$个怪物,每一天你可以选择一个英雄去消灭怪物,并且你只能一个一个的消灭,不能改变顺序,当一个英雄的能力值大于等于怪物的能力值并且他这一天内消灭的怪物数小于$s[i]$时,他就会继续去消灭下一个怪物,直到消灭的怪物数量等于$s[i]$或者这个英雄的能力值小于当前怪物的能力值,结束这一天,进入第二天,一个英雄可以使用多次,问消灭所有怪物最少的天数。 思路:当英雄最大的能力值小于怪物最大的能力值时,不可能把所有怪物消灭,直接输出$-1$,考虑有解时,显然当两个英雄的耐力值$s[i]$相等时,我们会选择能力值大的那个英雄去消灭怪物,所以我们定义$b[i]$表示耐力值至少为$i$(至少能消灭$i$只怪)的英雄中最大的能力值,显然$b[i]$从$n$到$1$是非递减的。设在某一天内已经消灭了$k$只怪物,因为一天只能选择一个英雄,所以在消灭第$k+1$只怪物时,如果这一天内怪物能力的最大值$now$大于$b[k+1]$,则应该结束这一天,第二天又从最大值$b[1]$开始消灭怪物。 注意:$b[i]$数组的求法,从后先前,每次$b[i]=max(b[i],b[i+1])$ #include

Educational Codeforces Round 80 (Rated for Div. 2) B

♀尐吖头ヾ 提交于 2020-01-16 03:50:55
B. Yet Another Meme Problem 传送门 # include <stdio.h> int main ( ) { int t ; for ( scanf ( "%d" , & t ) ; t -- ; ) { long long n , d , c = 0 , t = 9 ; scanf ( "%lld %lld" , & n , & d ) ; while ( t <= d ) { static_cast < void > ( c ++ ) , t = t * 10 + 9 ; } printf ( "%lld\n" , n * c ) ; } return 0 ; } 来源: CSDN 作者: king9666 链接: https://blog.csdn.net/king9666/article/details/103996271

Educational Codeforces Round 80 (Rated for Div. 2) ABCDE 题解

你说的曾经没有我的故事 提交于 2020-01-16 00:41:47
Educational Codeforces Round 80 (Rated for Div. 2) A. Deadline 如果n>=d 直接yes 否则对于公式 \(x+ceil(d/(x+1))<=n\) 两边同时乘以x+1 会得到一个关于x的一元二次方程, 通过求根公式解出较小的那一个根x1, 然后在 \(x1+-3\) 的范围内找到 \(x+ceil(d/(x+1))\) 的最小值与n比较即可。 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <queue> #include <stack> #include <map> #include <set> #include <vector> #include <iomanip> #define ALL(x) (x).begin(), (x).end() #define sz(a) int(a.size()) #define rep(i,x,n) for(int i=x;i<n;i++) #define repd(i,x,n) for(int i=x;i<=n;i++) #define pii pair<int,int> #define pll pair<long

Educational Codeforces Round 80 (Rated for Div. 2) D. Minimax Problem(二分+状压dp判断)

拟墨画扇 提交于 2020-01-16 00:25:55
题目链接 学习题解 这种状压题 cf 之前出过: Codeforces Round #590 (Div. 3) F. Yet Another Substring Reverse 题意很好懂,由于是求 最小值最大 于是二分这个最小值最大。 然后将a[i][j] 数组没一行变成一个整数,方法:a[i][j] 大于 mid s[i]整数二进制上第j位就是1 若任意两个整数的异或值等于 (1<<m)-1,那么就代表这两个整数 所代表的 数组,经过题目条件的变化,使得b数组的 的最小值大于当前二分值mid,那么这个mid是合法的。 #include<bits/stdc++.h> using namespace std; const int N=3e5+10,M=10,inf=0x3f3f3f3f; int n,m; int a[N][M],sta[1<<9],f[10]; int s[N],ans1,ans2; bool cal(int mid) { memset(sta,0,sizeof(sta)); for(int i=1;i<=n;++i){ s[i]=0; for(int j=1;j<=m;++j){ if(a[i][j]>=mid) s[i]|=f[j]; } sta[s[i]]=i; } int len=(1<<m)-1; for(int i=len;i>=1;--i){ if

Educational Codeforces Round 80 (Rated for Div. 2) 题解

╄→尐↘猪︶ㄣ 提交于 2020-01-15 23:33:23
Deadline Yet Another Meme Problem Two Arrays Minimax Problem Messenger Simulator Deadline \[ Time Limit: 2 s\quad Memory Limit: 256 MB \] 这是个对勾函数,所以最小的话是在 \(sqrt\) 位置,所以只要找这附近的数字就可以了。 view /*************************************************************** > File Name : a.cpp > Author : Jiaaaaaaaqi > Created Time : 2020/1/14 22:35:48 ***************************************************************/ #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define pii pair<int, int> #define dbg(x) cout << #x << " = " << (x) << endl #define mes(a, b) memset(a, b, sizeof a)

Educational Codeforces Round 80 (Rated for Div. 2)思维状压

烂漫一生 提交于 2020-01-15 21:56:04
题:https://codeforces.com/contest/1288/problem/D 题意:给定n个序列,每个序列m个数,求第i个和第j个序列组成b序列,b序列=max(a[i][k],a[j][k]),使得b序列最小值最大化,求达成条件的 i 和 j (i可等于j) 分析:因为m<=8,所以我们考虑对每个序列的m个数进行状压。    这题的状压是,“1”状态,表示取max取到了这个位置,“0”就表示max没取到这个位置。    因为题目要求很明确,要b序列最小值最大化,所以我们不用考虑取max后哪个数覆盖哪个数, 只需考虑最小值应该是第几个序列即可 。    然后就对应俩个序列进行最大化匹配即可 #include<bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back const int inf=0x3f3f3f3f; const ll INF=1e18; const int M=1e3+5; int a[10]; int maxx[M],maxid[M]; int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++) scanf("%d",&a[j]);

Educational Codeforces Round 79 (Rated for Div. 2) - D. Santa's Bot(数论)

烂漫一生 提交于 2020-01-15 20:22:12
题意:有$n$个孩子,第$i$个孩子有$k[i]$件想要的礼物,第$j$个礼物为$a[i][j]$,现在随机挑一个孩子,从他想要的礼物里面随机挑一个,然后送给另一个孩子$($这个孩子可以和第一个孩子是同一个人$)$,问你送的这个礼物在后一个孩子愿望单里的概率。 思路:求出每件礼物出现的次数$cnt[]$,挑出第一个孩子的概率为$\frac{1}{n}$,在他的愿望单里挑出一件礼物的概率为$\frac{1}{k[i]}$,挑出另一个孩子的概率也是$\frac{1}{n}$,挑出的第一个孩子的每件礼物$a[i][j]$出现了$cnt[a[i][j]]$次,那么对于第$i$个孩子的第$j$件礼物$a[i][j]$礼物而言,对答案的贡献就是$\frac{cnt[a[i][j]]}{n^{2}*k[i]}$,所以总概率$$p=\sum_{i=1}^{n}\sum_{j=1}^{k[i]}\frac{cnt[a[i][j]]}{n^{2}*k[i]}$$用快速幂取逆元。 #include <iostream> #include <cstdio> #include <algorithm> #include <vector> using namespace std; typedef long long ll; const int N = 1000010; const ll mod =

Educational Codeforces Round 80 (Rated for Div. 2)C(DP)

≯℡__Kan透↙ 提交于 2020-01-15 14:03:32
1 #define HAVE_STRUCT_TIMESPEC 2 #include<bits/stdc++.h> 3 using namespace std; 4 const long long mod = 1e9+7; 5 long long pre[1007][1007],temp[1007][1007]; 6 int main(){ 7 ios::sync_with_stdio(false); 8 cin.tie(NULL); 9 cout.tie(NULL); 10 int n,m; 11 cin>>n>>m; 12 for(int i=1;i<=n;++i){ 13 pre[1][i]=1; 14 temp[1][i]=1; 15 } 16 for(int i=2;i<=m;++i)//当前位 17 for(int j=1;j<=n;++j)//第i位以数字j结尾 18 for(int k=1;k<=j;++k)//保证非降序 19 pre[i][j]=(pre[i][j]+pre[i-1][k])%mod;//状态转移 20 for(int i=2;i<=m;++i)//当前位 21 for(int j=1;j<=n;++j)//第i位以数字j结尾 22 for(int k=j;k<=n;++k)//保证非升序 23 temp[i][j]=(temp[i][j]

Educational Codeforces Round 80 (Rated for Div. 2)(BYet Another Meme Problem)

[亡魂溺海] 提交于 2020-01-15 01:57:34
(B)Yet Another Meme Problem 题目 : 思路:找b中9,99,999,999.。。。比b小的这些个数,然后相乘就行。。。 #include<bits/stdc++.h> using namespace std; int main() { //freopen("text","r",stdin); int T; scanf("%d",&T); while(T--) { long long a,b; cin>>a>>b; if(b<9) printf("0\n"); else{ if(b<99) cout<<a<<endl; else if(b<999) cout<<a*2<<endl; else if(b<9999) cout<<a*3<<endl; else if(b<99999) cout<<a*4<<endl; else if(b<999999) cout<<a*5<<endl; else if(b<9999999) cout<<a*6<<endl; else if(b<99999999) cout<<a*7<<endl; else if(b<999999999) cout<<a*8<<endl; else cout<<a*9<<endl; } } return 0; } 来源: https://www.cnblogs.com/Vampire6/p