博客
关于我
It‘s All In The Mind HDU - 5742(贪心,)
阅读量:239 次
发布时间:2019-03-01

本文共 734 字,大约阅读时间需要 2 分钟。

 

#include 
#include
#include
#include
#include
#include
using namespace std;const int maxn=1e6+5;int a[maxn];int main(){ int t; cin>>t; while(t--){ memset(a,0,sizeof(a));//一定要初始化,这里WA了好多次 int n,m; cin>>n>>m; int flag1=0,flag2=0; for(int i=1;i<=m;i++){ int x,y; cin>>x>>y; a[x]=y; if(x==1)flag1=1; if(x==2)flag2=1; } if(!flag1&&flag2)a[1]=100; if(flag1&&!flag2)a[2]=a[1]; if(!flag1&&!flag2)a[1]=a[2]=100; //if(flag1&&flag2); int temp=0,flag=0; for(int i=n;i>=3;i--){ if(a[i]==0&&flag==0)a[i]=0; else{ if(a[i]){ flag=1; temp=a[i]; } else if(!a[i]&&flag)a[i]=temp; } } int sum2=0; for(int i=n;i>=1;i--){ sum2+=a[i]; } int sum1=a[1]+a[2]; int gcd=__gcd(sum1,sum2);//__gcd()是两个下划线 cout<

 

转载地址:http://hfnt.baihongyu.com/

你可能感兴趣的文章
Nacos2.X 配置中心源码分析:客户端如何拉取配置、服务端配置发布客户端监听机制
查看>>
NacosClient客户端搭建,微服务注册进nacos
查看>>
Nacos做注册中心使用
查看>>
Nacos原理
查看>>
Nacos发布0.5.0版本,轻松玩转动态 DNS 服务
查看>>
Nacos启动异常
查看>>
Nacos和Zookeeper对比
查看>>
Nacos在双击startup.cmd启动时提示:Unable to start embedded Tomcat
查看>>
Nacos如何实现Raft算法与Raft协议原理详解
查看>>
Nacos安装教程(非常详细)从零基础入门到精通,看完这一篇就够了
查看>>
Nacos实战攻略:从入门到精通,全面掌握服务治理与配置管理!(下)
查看>>
Nacos心跳机制实现快速上下线
查看>>
Nacos服务注册与发现demo
查看>>
Nacos服务注册总流程(源码分析)
查看>>
nacos服务注册流程
查看>>
Nacos服务部署安装
查看>>
nacos本地可以,上服务器报错
查看>>
Nacos注册中心有几种调用方式?
查看>>
nacos注册失败,Feign调用失败,feign无法注入成我们的bean对象
查看>>
nacos源码 nacos注册中心1.4.x 源码 nacos源码如何下载 nacos 客户端源码下载地址 nacos discovery下载地址(一)
查看>>