传送门

出题人说正解为RMQ,鄙人实在太蒟蒻了,不会呀只能暴力……

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
const int N=1e6+;
const int mod=1e9+;
void read(int &a)
{
a=;
int d=;
char ch;
while(ch=getchar(),ch>''||ch<'')
if(ch=='-')
d=-;
a=ch-'';
while(ch=getchar(),ch>=''&&ch<='')
a=a*+ch-'';
a*=d;
}
void write(int x)
{
if(x<)
putchar(),x=-x;
if(x>)
write(x/);
putchar(x%+'');
}
int a[N];
int GCD(int a,int b)
{
return b==?a:GCD(b,a%b);
}
int main()
{
int n;
read(n);
ll ans=,gcd;
read(a[]);
gcd=a[];
for(re int i=;i<n;i++)
read(a[i]),gcd=GCD(gcd,a[i]);
for(re int i=;i<n;i++)
{
int now=a[i];
for(re int j=i;j<n;j++)
{
if(now==gcd)
{
ans=(ans+(n-j)*gcd)%mod;
break;
}
now=GCD(now,a[j]);
ans+=now;
ans%=mod;
}
}
write(ans);
return ;
}

Parco_Love_gcd的更多相关文章

随机推荐

  1. cx_oracle访问处理oracle中文乱码问题

    cx_oracle访问处理oracle中文乱码问题 问题描述 使用docker打包了centos镜像,编码为gbk,随后访问oracle出现了很多乱码.其原因自然是因为编码不一致,服务器为zhs16g ...

  2. hdoj:2053

    #include <iostream> #include <string> #include <vector> using namespace std; /* 无穷 ...

  3. redhat杂记

    1.设置sudo权限:修改/etc/sudoers文件,找到root    ALL=(ALL)       ALL,在后面添加nginx ALL=(ALL) NOPASSWD: ALL 2.用sed命 ...

  4. 第四百零六节,自定义用户表类来继承Django的用户表类,

    第四百零六节,自定义用户表类来继承Django的用户表类, models.py from django.db import models # Create your models here. from ...

  5. SpringMvc中获取Request

    Controller中加参数 @Controller public class TestController { @RequestMapping("/test") public v ...

  6. MySQL yum 在线与本地包方式安装

     以下实践操作是在 liux-centos7 上安装配置 先检测是否安装mysql,然后在拆卸mysql # 检测[root@localhost ~]# yum list installed | gr ...

  7. GLSL传递数组

    static const char *microshaderFragSource = { "varying vec4 color;\n" "uniform bool te ...

  8. ArcGIS删除数据异常崩溃

    环境 ArcGIS Desktop10.1,ArcSDE10.1,Oracle 11.2.0.4客户端和服务器端(服务器端搭建RAC集群) 问题描述 在使用ArcCatalog连接数据库进行数据删除时 ...

  9. Qt编写自定义控件6-指南针仪表盘

    前言 指南针仪表盘,主要用来指示东南西北四个方位,双向对称两个指针旋转,其实就是360度打转,功能属于简单型,可能指针的绘制稍微难一点,需要计算多个点构成多边形,本系列控件文章将会连续发100+篇,一 ...

  10. node.js用logio实时监控log

    http://logio.org/ 1.先装好node.js $ yum install nodejs 2.安装log.io $sudo npm install -g log.io --user &q ...