Codeforces Global Round 15 (A-D)没有C

A

太简单,写完删了

B
我写的繁了,但是意思是这么个意思,就遍历打擂台一样,找到最后的胜者,然后在遍历一遍找是不是最厉害的

#include <bits/stdc++.h>
using namespace std;
#define int long long
int op[200095][16];
signed main()
{int t;cin >> t;while (t--){int n;cin >> n;int k = -1;int maxn[6];memset(maxn, 0x3f3f3f3f, sizeof(maxn));int ch[6];for (int j = 1; j <= n; j++){int cou = 0;for (int i = 0; i < 5; i++){cin >> ch[i];op[j][i] = ch[i];if (ch[i] < maxn[i])cou++;}if (cou >= 3){for (int i = 0; i < 5; i++){maxn[i] = ch[i];}k = j;}}bool flag = true;for (int i = 1; i <= n; i++){int cou = 0;if (i != k)for (int j = 0; j < 5; j++){if (maxn[j] < op[i][j])cou++;}elsecou = 5;if (cou < 3){flag = false;break;}}if (flag)cout << k << endl;elsecout << -1 << endl;}
}

D
别人代码,直接拿来用了
应该是最精简的了

#include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
int a[101000];
int n,flag = 0;
void dfs(int now,int all)
{if(now == n){if(mp[all]!=0){flag = 1;}mp[all] ++;return ;}now ++;dfs(now,all + a[now]);dfs(now,all);
}
int main()
{int T;scanf("%d",&T);while(T--){scanf("%d",&n);for(int i = 1;i<=n;i++){scanf("%d",&a[i]);}mp.clear();flag = 0;dfs(0,0);if(flag){printf("YES\n");}else{printf("NO\n");}}
}

tourist代码:
思路一个数可以取或者取反例,或者不取

#include <bits/stdc++.h>
using namespace std;
int main() {ios::sync_with_stdio(false);cin.tie(0);int tt;cin >> tt;while (tt--) {int n;cin >> n;vector<int> a(n);for (int i = 0; i < n; i++) {cin >> a[i];}int p3 = 1;for (int i = 0; i < n; i++) {p3 *= 3;}bool found = false;for (int t = 1; t < p3; t++) {int tmp = t;int sum = 0;for (int i = 0; i < n; i++) {int d = tmp % 3;if (d == 1) sum += a[i];if (d == 2) sum -= a[i];tmp /= 3;}if (sum == 0) {found = true;break;}}cout << (found ? "YES" : "NO") << '\n';}return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/428736.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Codeforces Round #434 (Div. 2)【A、B、C、D】

Codeforces Round #434 (Div. 2) codeforces 858A. k-rounding【水】 题意&#xff1a;已知n和k&#xff0c;求n的最小倍数x&#xff0c;要求x后缀至少有k个0。 题解&#xff1a;答案就是10^k和n的最小公倍数。 1 #include<cstdio>2 #include<cstring>3 #include&l…

Codeforces Round #735 (Div. 2)(A-D)没有B

Codeforces Round #735 (Div. 2) A 一道小思维题 #include <bits/stdc.h> using namespace std; #define int long long const int N 1000100; int a[N]; signed main() {int t;cin>>t;while(t--){int n;cin>>n;int cou 0;for (int i1;i<n;i){cin>&…

Educational Codeforces Round 112 (Rated for Div. 2)(A-D)

Educational Codeforces Round 112 (Rated for Div. 2) A 我写的挺烦的&#xff0c;其实判断一下奇偶数和有没有a>0就行 #include <bits/stdc.h>using namespace std;#define int long longsigned main(){int t;cin>>t;while (t--){int n;cin>>n;int a n…

PLC与触摸屏练习

电机正反转 触摸屏 要用触摸屏进行仿真是不要忘了先启动梯形图测试 效果 1-2例 行程开关控制的自动循环 梯形图 触摸屏 下面只是用了四个开关&#xff0c;可以根据自己想要实现的按照梯形图添加 题目 梯形图 电动机星三角减压启动控制 题目及要求 触摸屏截图 运算 把显示的数值…

Django里面是文件静态化的方法

看Django官网的时候&#xff0c;由于自己的英语基础较差&#xff0c;而实现的谷歌翻译比较烂&#xff0c;只能看懂个大概。在文件静态化的时候&#xff0c;讲的比较繁琐一点&#xff0c;没怎么看懂&#xff0c;遂询问了一下其他人&#xff0c;明白了许多&#xff0c;但是细节需…

Codeforces Round #736 (Div. 2)(B-C)

Codeforces Round #736 (Div. 2) 花了十分钟帮朋友写了B&#xff0c;C就睡觉了&#xff0c;自己没打 B 先看上&#xff0c;再看左后看右 #include <iostream> #include <cstring> #include <algorithm> using namespace std; #define int long long signed…

RabbitMQ 声明Queue时的参数们的Power

RabbitMQ 声明Queue时的参数们的Power 参数们的Power 在声明队列的时候会有很多的参数 public static QueueDeclareOk QueueDeclare(this IModel model, string queue "", bool durable false, bool exclusive true, bool autoDelete true, IDictionary<strin…

解决Firefox已阻止运行早期版本Adobe Flash

解决Firefox已阻止运行早期版本Adobe Flash 类别 [随笔分类]web 解决Firefox已阻止运行早期版本Adobe Flash 最近火狐浏览器不知抽什么风&#xff0c;每次打开总提示"Firefox已阻止(null)运行早期版本的Adobe Flash"。要命的是它提示的解决办法根本不管用&#xf…

误删path怎么办(已重启)

我是在设置环境变量的时候不懂&#xff0c;新建了一个path&#xff0c;导致我原来的path没了。 但是居然jdk能用。。。。。不太懂。 不要慌&#xff0c;大不了重装系统。其实只要再重新新建就行了。 C:\Program Files\Common Files\Siemens\Automation\Simatic OAM\bin;%Syste…

一个容易被忽视的css选择器

之前学的的迷糊了&#xff0c;也不知道什么会什么不会了&#xff0c;跑去面试了。别人列出一堆css选择器&#xff0c;本以为选择器没啥的&#xff0c;结果到那个多类选择器翻车了&#xff0c;.a.b选择同时含a,b类名的&#xff0c;很尴尬所以回来仔细整理了一下。目前根据W3C手册…

Codeforces Round #756 (Div. 3)

Codeforces Round #756 (Div. 3) A. Make Even 思路&#xff1a;如果末尾是偶数&#xff0c;不需要操作&#xff1b;如果开头是偶数&#xff0c;一次操作&#xff0c;即全翻转&#xff1b;如果开头和末尾都是 奇数&#xff0c;判断里面是否有偶数&#xff0c;如果没有&#xff…

使用MyBatista----上传图像

使用MyBatis上传图像&#xff0c;使用的是Oracle的数据库表&#xff0c;有一个TEACHER表&#xff0c;有7列&#xff0c;有1列是存储图片的&#xff0c;类型用BLOB&#xff0c;最大容量是4G&#xff0c;以二进制的形式写入数据库表。 建立这个表的对应实体类Teacher&#xff0c;…

189A. Cut Ribbon

A. Cut Ribbon:题目地址 题意&#xff1a;一条长为n的彩带切割&#xff0c;切割后每段长度是a或者是b或者是c#include <bits/stdc.h> using namespace std; typedef long long ll; vector<int> a((int)4e5); vector<int> b((int)4e5); int main() {int n,a,…

作业1.3

public class Work{   public static void main(String[] args)   {     System.out.println(" J A V V A");     System.out.println(" J A A V V A A"); //直接输出就好了     System.out.println("J J …

476B. Dreamoon and WiFi

B. Dreamoon and WiFi:题目链接 题意&#xff1a;给你一个正常的走向&#xff0c;在给你一个虚假和不确定的走向&#xff0c;问到达的可能性#include <bits/stdc.h> using namespace std; string str1, str2; double C(double A, double B) {double res 1.0;for (int i…

简易观察者模式

var Event {   on(event,callback){     if(!this.handles){       this.handles {};     }     if(!this.handles[event]){       this.handles[event] [];     }     this.handles[event].push(callback);   },   emit(event){   …

1360E. Polygon

E. Polygon&#xff1a;题目 题意&#xff1a;在一个n*n的方块空间内&#xff0c;上下都有大炮&#xff0c;发射数量和先后由你决定。问能否得到他给的地图。 思路&#xff1a;如果他不是靠下边或者右边&#xff0c;右或者下必有一个炮弹阻挡。所以直接遍历判断就行#include &…

1470A. Strange Birthday Party

A. Strange Birthday Party&#xff1a;题目 题意&#xff1a;有n个朋友&#xff0c;要么给他钱&#xff0c;要么给他买礼物&#xff0c;礼物每样只能买一个 思路&#xff1a;sort&#xff0c;给钱不如给礼物的给礼物&#xff0c;礼物给完了&#xff0c;或者礼物本身太贵不如给…

_INTSIZEOF

在_INTSIZEOF中该有的都有了 1.这其中最小非负剩余和最大正余数例子如下: 设n为4&#xff0c;当r为1时&#xff0c;最小非负剩余就是1&#xff0c;最大非正剩余就是1 - 4 -3&#xff0c;最大正余数为4 - 1 3 2.x nq r推导出qn ((x n - 1) / n) * n的过程如下 1)当x % n等…

Windows下struct和union字节对齐设置以及大小的确定(一 简介和结构体大小的确定)...

在windows下设置字节对齐大小的方式&#xff0c;目前我了解有三种&#xff1a; 1. 在编译程序时候的编译选项 /Zp[n]&#xff0c;如 cl /Zp4 表示对齐大小是4字节&#xff1b; 2. 预处理命令 #pragma pack( [ show ] | [ push | pop ] [, identifier ] , n )&#xff1b; 3…