rated

Educational Codeforces Round 71 (Rated for Div. 2) Solution A~G

时光总嘲笑我的痴心妄想 提交于 2019-11-28 07:03:00
A. There Are Two Types Of Burgers 题意: 给一些面包,鸡肉,牛肉,你可以做成鸡肉汉堡或者牛肉汉堡并卖掉 一个鸡肉汉堡需要两个面包和一个鸡肉,牛肉汉堡需要两个面包和一个牛肉 求能得到的最多的钱 直接贪心,哪个比较贵就选哪个做,剩下的材料再做另一个 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; typedef long long ll; inline int read() { int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); } return x*f; } const int N=2e5+7; int T,n,a,b,va,vb; int main() { T=read(); while(T--) { n=read(),a=read(),b=read(); va=read(),vb=read(); if(va>vb) {

Educational Codeforces Round 71 (Rated for Div. 2) E XOR Guessing (二进制分组,交互)

☆樱花仙子☆ 提交于 2019-11-28 06:41:11
E. XOR Guessing time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You may also refer to the guide on interactive problems: https://codeforces.com/blog/entry/45307 . The jury picked an integer x not less than 0 and not greater than

Educational Codeforces Round 69 (Rated for Div. 2)

谁都会走 提交于 2019-11-27 18:02:54
A. DIY Wooden Ladder time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Let's denote a k k-step ladder as the following structure: exactly k + 2 k+2 wooden planks, of which two planks of length at least k + 1 k+1 — the base of the ladder; k k planks of length at least 1 1 — the steps of the ladder; Note that neither the base planks, nor the steps planks are required to be equal. For example, ladders 1 1 and 3 3 are correct 2 2-step ladders and ladder 2 2 is a correct 1 1-step ladder. On the first picture the lengths of planks are [ 3 ,

Educational Codeforces Round 70 (Rated for Div. 2)

一曲冷凌霜 提交于 2019-11-26 20:43:36
A: http://codeforces.com/contest/1202/problem/A 思路:找出第二个串最后一个1的位置 在第一个串的这个位置及之前找 第一个1的位置,两个位置相减就是答案. AC代码: 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1e5 + 5; 4 const int INF = 0x3f3f3f3f; 5 int n; 6 int main() 7 { 8 int t; 9 string a, b; 10 cin >> t; 11 while(t--) 12 { 13 cin >> a >> b; 14 reverse(a.begin(),a.end()); 15 reverse(b.begin(),b.end()); 16 int p = 0; 17 for(int i = 0;i < b.size();i++) 18 { 19 if(b[i] == '1') 20 { 21 p = i;break; 22 } 23 } 24 int v = 0; 25 for(int i = p;i <= a.size();i++) 26 { 27 if(a[i] == '1') 28 { 29 v = i; 30 break; 31 } 32 } 33 cout <<

Educational Codeforces Round 70 (Rated for Div. 2)

痴心易碎 提交于 2019-11-26 20:23:34
Educational Codeforces Round 70 (Rated for Div. 2) 题目链接 A. You Are Given Two Binary Strings... 注意到乘以一个 \(2^k\) 就相当于将二进制左移 \(k\) 位,然后贪心匹配就行了:找到 \(t\) 串最后一个 \(1\) 的位置,然后尽可能地去匹配 \(s\) 串后面的 \(1\) 。 Code #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 5; int T; char s[N], t[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> T; while(T--) { cin >> s + 1 >> t + 1; int n = strlen(s + 1), m = strlen(t + 1); int p = 1; for(int i = m; i >= 0; i--) { if(t[i] == '1') break; p++; } int ans = 0; for(int i = n - p + 1; i >= 0; i--) { if(s[i] == '1') break;

Educational Codeforces Round 70 (Rated for Div. 2)

吃可爱长大的小学妹 提交于 2019-11-26 15:52:00
这次真的好难...... 我这个绿名蒟蒻真的要崩溃了555... 我第二题就不会写...... 暴力搜索MLE得飞起。 好像用到最短路?然而我并没有学过,看来这个知识点又要学。 后面的题目赛中都没看,今天早上看了一下D发现还是能写的。 A.You Are Given Two Binary Strings... 简单来说,对f(y)乘以2的k次,实际上就是把这个串左移k位。要使反转的串的字典序最小,就要让f(y)最后的1与f(x)的最后的1的位置对齐。 #include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; while(n--) { string a,b; cin>>a>>b; reverse(a.begin(),a.end()); reverse(b.begin(),b.end()); int a1; int b1=b.find('1'); for(int i=b1;i<a.length();i++) { if(a[i]=='1') { a1=i; break; } } if(a1<=b1)cout<<0<<'\n'; else cout<<a1-b1<<'\n'; } return 0; } D.Print a 1337-string... 构造问题,一步一步考虑: 先假设答案为