【计蒜客】摇钱树

2024-03-12 12:50
文章标签 计蒜客 摇钱树

本文主要是介绍【计蒜客】摇钱树,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

注意unsigned long long int 比long long int表示的范围要大,前者能表示-2^63+1~2^63-1,后者能表示的范围是0~2^64-1,与题目中的范围相符,这个问题导致我浪费了很多时间。。。。。。

#include <iostream>using namespace std;
int main()
{unsigned long long int m,n;cin>>m>>n;unsigned long long int temp;for(int i=0;i<n;i++){cin>>temp;m=m-temp;if(m<=0){int w=i+1;cout<<-w<<endl;break;}m=m*2;}if(m>0){cout<<m<<endl;}
}

这篇关于【计蒜客】摇钱树的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/801309

相关文章

计蒜客 Skiing 最长路

In this winter holiday, Bob has a plan for skiing at the mountain resort. This ski resort has MM different ski paths and NN different flags situated at those turning points. The ii-th path from the

计蒜客 Half-consecutive Numbers 暴力打表找规律

The numbers 11, 33, 66, 1010, 1515, 2121, 2828, 3636, 4545 and t_i=\frac{1}{2}i(i+1)t​i​​=​2​​1​​i(i+1), are called half-consecutive. For given NN, find the smallest rr which is no smaller than NN

计蒜客 李白喝酒

感觉这题很有趣,虽然是用来举例二进制的 一天,他提着酒壶,从家里出来,酒壶中有酒两斗。他边走边唱: 无事街上走,提壶去打酒。 逢店加一倍,遇花喝一斗。 一路上,他一共遇到店5次,遇到花10次,已知最后一次遇到的是花,他正好把酒喝光。清计算李白遇到店的和花的次序, 有多少可能的方案。 int ans=0;//方案数 for(int i=0;i<(1<<14);i++){//暴力枚

计蒜客 T1797 最小数和最大数

题目链接:https://nanti.jisuanke.com/t/T1797 算法特工队QQ群:979618872 (伸手党绕边,欢迎有良好基础的人加入) //// Created by Leo Lee on 2019/4/5.//#include <iostream>using namespace std;int main(){int counts;cin>>counts;int t

计蒜客 T1725 国王的魔镜

题目链接:https://nanti.jisuanke.com/t/T1725 算法特工队QQ群:979618872 (伸手党绕边,欢迎有良好基础的人加入) //// Created by Leo Lee on 2019/4/5.//#include <iostream>#include <string>using namespace std;unsigned long minLong

计蒜客 T1677 农场周围的道路

题目链接:https://nanti.jisuanke.com/t/T1677 算法特工队QQ群:979618872 (伸手党绕边,欢迎有良好基础的人加入) //// Created by Leo Lee on 2019/4/5.//#include <iostream>using namespace std;void getGroups(int bulls,int k);int gr

计蒜客 T1560 二分查找(一)

题目链接:https://nanti.jisuanke.com/t/T1560 算法特工队QQ群:979618872 (伸手党绕边,欢迎有良好基础的人加入) //// Created by Leo Lee on 2019/4/5.//#include <iostream>#include <algorithm>using namespace std;long long arr[1000

计蒜客 T1319 质数判定一

题目链接:https://nanti.jisuanke.com/t/T1319 算法特工队QQ群:979618872 (伸手党绕边,欢迎有良好基础的人加入) //// Created by Leo Lee on 2019/4/5.//#include <iostream>#include <math.h>using namespace std;bool isprime(long lon

计蒜客 T1109 字符替换

题目链接:https://nanti.jisuanke.com/t/T1109 https://nanti.jisuanke.com/t/T1109 //// Created by Leo Lee on 2019/4/5.//#include <iostream>#include <string>using namespace std;int main(){string str;cha

计蒜客 T1044 最大数输出

题目链接:https://nanti.jisuanke.com/t/T1044 算法特工队QQ群:979618872 (伸手党绕边,欢迎有良好基础的人加入) //// Created by Leo Lee on 2019/4/5.//#include <iostream>using namespace std;int main(){int max = INT32_MIN,tmp;for(