https://codeforces.com/contest/1183/problem/F

题解:排序+朴素

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=200000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
int a[N];
char str;
struct node{};
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);scanf("%d",&t);while(t--){scanf("%d",&n);for(int i=0;i<n;i++)scanf("%d",&a[i]);sort(a,a+n,greater<int>());n = unique(a,a+n) - a;ans = 0;for (int i = 0;i < n;++i){int x = a[i];ans = max(ans,x);bool flag = 0;if (i == n-1) break;for (int j = i+1;j < n;++j){if (a[i] % a[j] == 0) continue;int y = a[j];ans = max(ans,y+x);if (j == n-1) break;for (int k = j+1;k < n;++k){if (a[i]%a[k] == 0 || a[j] % a[k] == 0) continue;ans = max(ans,x+y+a[k]);flag = 1;break;}if (flag == 1) break;}}printf("%d\n",ans);}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}

Topforces Strikes Back相关推荐

  1. Smartbanner: Intelligent banner design framework that strikes a balance between freedom and rules

    smartbanner是智能合图系列产品,具体可见论文:Smartbanner: intelligent banner design framework that strikes a balance ...

  2. CF1081G Mergesort Strikes Back

    题目大意: 给定\(n\),\(k\),\(mod\),求随机排列在\(k\)层归并排序下逆序对的期望. 题解 考虑这\(k\)层归并会把序列分成若干个块. 这些块内的顺序是原序列的相对顺序,我们要把 ...

  3. CF1379F1 Chess Strikes Back (easy version)(鸽笼原理、线段树)

    解析 很神奇的一道题 关键在于把22的正方形看成一个单位的转化 由于每个22最多有一个国王 因此每个2*2都一定有一个国王 这是本题的关键 个人感觉这个思想很像鸽笼原理 至于后面的线段树就水到渠成了 ...

  4. Codeforces Gym 101142C:CodeCoder vs TopForces(搜索)

    http://codeforces.com/gym/101142/attachments 题意:每个人在TC和CF上分别有两个排名,如果有一个人在任意一个网站上大于另一个人的排名,那么这个人可以打败另 ...

  5. D. Masquerade strikes back(思维)

    https://codeforces.com/gym/101911/problem/D 题解: set打表存因子会炸  数据大到1e7,开不了 所以看代码:得先找到重复的几个数直接挨个分配一组因子 # ...

  6. URAL 1646 Godzilla Strikes Back!

    题目链接:点击打开链接 #include<stdio.h> #include<string.h> #include<iostream> #include<al ...

  7. CF 780 D. Maximum Product Strikes Back

     Problem - D - Codeforces 题目大意:找到一个连续的区间,此区间乘积最大,区间长度0时答案为1,输出区间左边删除数量和右边删除的数量.直接输出区间不好吗??? 解题思路:查询序 ...

  8. Boom Library 93套影视游戏无损配乐音效素材合集包

    Boom Library 93套影视游戏无损配乐音效素材合集包 素材压缩包大小共:851G 每个合集为独立压缩包 可选择性下载 云桥网络 平台获取合集包 01.BOOM Library Assault ...

  9. 每日英语:China's Labor Market Tightens

    Job cuts in China appear to be on the rise, dimming prospects for a labor market that has been a res ...

最新文章

  1. SQL Server DATEADD() 函数
  2. Octavia 项目加速 OpenStack LBaaS 落地大规模应用场景
  3. 2019春第一周作业(计算机)7.1
  4. 文献学习(part80-A)--Do we Need Hundreds of Classifiers to Solve Real World Classification Problems?
  5. 【软件开发底层知识修炼】十八 快速学习GDB调试五 使用GDB进行调试的一些小技巧
  6. linux图形驱动安装失败,红旗Linux 下NVIDIA的驱动安装问题
  7. 【原创】记一次HttpWebRequest中国移动查账单爬虫的攻克历程
  8. OKR与互联网创业团队
  9. ERP软件管理持续升级 抢占产业先机
  10. 剑指offer——面试题47:不用加减乘除做加法
  11. 在arcgis中进行拓扑检查
  12. matlab入门基础函数
  13. 2进制快速转换为16进制
  14. codeforces1467E Distinctive Roots in a Tree
  15. 国内外php商城系统 开源
  16. 近期有面试的必看!带你手撸红黑树,终获offer
  17. Chemdraw 基础操作【图文】
  18. Python汉字转换成拼音
  19. Java 获取当前年,前几年(之前年),后几年(之后年)
  20. vue2项目之async/await 处理 promis

热门文章

  1. 前端获取后端传来的session_java后台如何获取,前台传来的表单数据
  2. Mysql表结构升级_mysql表结构升级时根据字段是否存在执行相应操作
  3. java 正则 空格_Java中关于空格的正则表达式
  4. 统计消息总数_和公牛一战,库里创三个记录,耀眼的还是三分球总数
  5. linux应用程序调试方法,Linux应用程序使用写文件调试程序的方法
  6. jpa query oracle 参数int为空_撸一个预言机(Oracle)服务,真香!—中篇
  7. android 一个activity定时更新另一个activity的UI
  8. 五十一、结合百度API接口打造 Python小项目
  9. webpack 语法
  10. 半导体二极管和晶体三极管