BC第二场
GT and sequence
You are given a sequence of NN integers.
You should choose some numbers(at least one),and make the product of them as big as possible.
It guaranteed that the absolute value of any product of the numbers you choose in the initial sequence will not bigger than 2^{63}-1263−1.
In the first line there is a number TT (test numbers).
For each test,in the first line there is a number NN,and in the next line there are NN numbers.
1 \leq T \leq 10001≤T≤1000 1 \leq N \leq 621≤N≤62
You'd better print the enter in the last line when you hack others.
You'd better not print space in the last of each line when you hack others.
For each test case,output the answer.
1
3
1 2 3
6
题解:各种考虑,细心点。。。。
ac代码:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
const int MAXN=;
typedef long long LL;
int cmp(LL a,LL b){
return a>b;
}
int main(){
int T,N;
LL m[MAXN];
scanf("%d",&T);
while(T--){
scanf("%d",&N);
LL x,ans=;
int zheng=,fu=,o=;
for(int i=;i<N;i++){
scanf("%I64d",&x);
if(x>)ans*=x,zheng++;
else if(x<)m[fu++]=-x;
else o++;
}
if(!zheng){
if(!fu){
puts("");continue;
}
else if(o&&fu==){
puts("");continue;
}
else if(!o&&fu==){
printf("%I64d\n",-m[]);
continue;
}
}
if(fu==){
printf("%I64d\n",ans);continue;
}
sort(m,m+fu,cmp);
//for(int i=0;i<fu;i++)printf("%d ",m[i]);puts("");
for(int i=;i<(fu/)*;i++)ans*=m[i];
printf("%I64d\n",ans);
}
return ;
}
GT and numbers
You are given two numbers NN and MM.
Every step you can get a new NN in the way that multiply NN by a factor of NN.
Work out how many steps can NN be equal to MM at least.
If N can't be to M forever,print -1−1.
In the first line there is a number TT.TT is the test number.
In the next TT lines there are two numbers NN and MM.
T\leq1000T≤1000, 1\leq N \leq 10000001≤N≤1000000,1 \leq M \leq 2^{63}1≤M≤263.
Be careful to the range of M.
You'd better print the enter in the last line when you hack others.
You'd better not print space in the last of each line when you hack others.
For each test case,output an answer.
3
1 1
1 2
2 4
0
-1
1
wa代码:
HACK
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
int cmd(int a,int b){
return a>b;
}
int main(){
__int64 T,N,M;
scanf("%I64d",&T);
__int64 fac[];
while(T--){
scanf("%I64d%I64d",&N,&M);
if(M%N!=){
puts("-1");
continue;
}
__int64 t=;
__int64 n=N;
for(__int64 i=;i<=n;i++){
if(n%i==){
fac[t++]=i;
}
}
n=M/N;
__int64 ans=;
sort(fac,fac+t,cmd);
for(__int64 i=;i<t;i++){
while(n%(fac[i])==)n/=fac[i],ans++;
}
// for(int i=0;i<t;i++)printf("%d ",fac[i]);puts("");
if(n==)printf("%I64d\n",ans);
else puts("-1");
}
return ;
}
BC第二场的更多相关文章
- 本周进步要点20161023(含李笑来第二场live笔记要点)
本周主要忙于去武汉参加iDOF2016智能数字油田会议,会上做了题为“油田SOA及云平台的系统思考与实践”的报告,为了准备这篇报告,用到了一些以前学过的知识,具体内容见“参加iDOF2016会议的收获 ...
- 2014百度之星预赛(第二场)——Best Financing
2014百度之星预赛(第二场)--Best Financing Problem Description 小A想通过合理投资银行理財产品达到收益最大化.已知小A在未来一段时间中的收入情况,描写叙述为两个 ...
- Contest1592 - 2018-2019赛季多校联合新生训练赛第二场(部分题解)
Contest1592 - 2018-2019赛季多校联合新生训练赛第二场 D 10248 修建高楼(模拟优化) H 10252 组装玩具(贪心+二分) D 传送门 题干 题目描述 C 市有一条东西走 ...
- 2018牛客暑期ACM多校训练营第二场(有坑未填)
第二场终于等来学弟 开始(被队友带飞)的开心(被虐)多校之旅 A run A题是一个递推(dp?)+前缀和 因为看数据量比较大 就直接上前缀和了 一个比较简单的递推 没有太多难点 签到题 需要注意 ...
- 2018牛客网暑假ACM多校训练赛(第二场)E tree 动态规划
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round2-E.html 题目传送门 - 2018牛客多校赛第二场 E ...
- NOI.AC NOIP模拟赛 第二场 补记
NOI.AC NOIP模拟赛 第二场 补记 palindrome 题目大意: 同[CEOI2017]Palindromic Partitions string 同[TC11326]Impossible ...
- DevOps Workshop 研发运维一体化(北京第二场) 2016.04.27
北京不亏为首都,人才济济,对微软DevOps解决方案感兴趣的人太多.我们与微软公司临时决定再家一场培训. 我之前在博客中(DevOps Workshop 研发运维一体化第一场(微软亚太研发集团总部)h ...
- CTF-i春秋网鼎杯第二场misc部分writeup
CTF-i春秋网鼎杯第二场misc部分writeup 套娃 下载下来是六张图片 直接看并没有什么信息 一个一个查看属性 没有找到有用信息 到winhexv里看一下 都是标准的png图片,而且没有fla ...
- 2018 计算之道初赛第二场 阿里巴巴的手机代理商(困难)(反向可持久化Trie)
阿里巴巴的手机代理商(困难) 阿里巴巴的手机代理商正在研究 infra 输入法的新功能.他们需要分析单词频率以改进用户输入法的体验.于是需要你在系统内核里面写一个 API. API 有如下功能: 添加 ...
随机推荐
- LeakCanary,检测安卓,java内存泄漏
官方中文API地址:http://www.liaohuqiu.net/cn/posts/leak-canary-read-me/
- 初识JavaScript,感觉整个人都不好了。。。
学习web前端的开发已经将近一个月了,开发中的三个大兄弟——“html”.“css”.“JavaScript”,小哥我已经深入接触了前两位,并与他俩建立的深厚的友谊.在编写过程中,不能说达到各位大神的 ...
- java设计模式之 单例模式 Singleton
static 的应用 单例模式 Singleton 单例:保证一个类在系统中最多只创建一个实例. 好处:由于过多创建对象实例,会产生过多的系统垃圾,需要GC频繁回收,由于GC会占用较大的系统资源,所有 ...
- [LeetCode]题解(python):151-Reverse Words in a String
题目来源: https://leetcode.com/problems/reverse-words-in-a-string/ 题意分析: 给定一个字符串,里面包括多个单词,将这个字符串的单词翻转,例如 ...
- 用不动点组合子解递归(python实现)
不动点组合子 Y = λf. (λx. f (x x)) (λx. f (x x)) θ = (λx. λy. (y(x x y))) (λx.λy.(y(x x y))) Y f = f (Y f) ...
- 組裝工廠設置IQC的目的
在電子組裝工廠的組織裡,一般都會有 IQC (Incoming Quality Control) 這個單位,台灣稱之為「入(進)料管控」,大陸稱之為「來料管控」,其最主要目的在攔檢所有買進材料是否符合 ...
- IE兼容性bug汇总
1.IE6的双边距BUG. 发生条件:如果有元素是浮动元素,则该元素与它的父元素(一般是一个容器)直接相接触(中间不能隔着其他元素)的左或右的边距就会产生双倍边距,也意味着相邻的兄弟元素不可能会产生双 ...
- Gdal 1.11.0 添加 Postgresql 9.1 sqlite3 支持
OS环境Ubuntu12.04 32bit 因为公司一个功能要用到gdal 的ogr2ogr命令转换shp数据,需要能往postgis和sqlite 中插入数据. 用gdal1.11.0的源码默认安装 ...
- linux环境之监听端口配置
export JAVA_OPTS="-Dcom.sun.management.jmxremote.port=18950 -Dcom.sun.management.jmxremote.auth ...
- C++_enum
C++的enum可以限制成员的类型 //error C2440: “=”: 无法从“int”转换为“color” #include <iostream> using namespace s ...