传送门

出题人说正解为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. 纯CSS3浮雕质感的立体文字旋转动画

    还记得之前分享过一个CSS3 文字3D翻转特效,这个效果让文字有一种立体的视觉效果.今天要分享的这款CSS3文字动画特效更加炫酷,它不仅有立体的3D效果,而且文字整体展现出一种浮雕质感的视觉效果,并且 ...

  2. 一次xxoo提权

    数据库root权限.然并卵. 看了一下phpinfo得知是mysql 5.0 的 然后想要通过udf之类的提权一波,结果一执行sql语句就被狗拦截了. 然而数据库这条路是GG了 OS 名称: Micr ...

  3. go语言fallthrough的用法心得

    fallthrough:Go里面switch默认相当于每个case最后带有break,匹配成功后不会自动向下执行其他case,而是跳出整个switch, 但是可以使用fallthrough强制执行后面 ...

  4. WireShark如何抓取本地localhost的包

    今天将自己的电脑既作为客户端又作为服务端进行一个程序的测试,想着用WireShark来抓包分析一下问题,但由于WireShark只能抓取经过电脑网卡的包,由于我是使用localhost或者127.0. ...

  5. C#访问gsoap的服务

    C++开发一个webservice,然后C#开发客户端,这样就需要C#的客户端访问gsoap的服务端.(大家都知道gsoap是C/C++开发webservice的最佳利器) 为什么不考虑直接用wcf开 ...

  6. hive建表报错:Specified key was too long; max key length is 767 bytes,hadoophive

    情况描述 Hive建表时报错,元数据存储在mysql中. 报错信息 如下: FAILED: Execution Error, bytes com.mysql.jdbc.exceptions.jdbc4 ...

  7. excel函数vloopup使用方法

    邮件处理,查找null手机号码  G1=VLOOKUP(F1,A:B,2,FALSE)      H1=VLOOKUP(F1,A:F,7,FALSE)参数1是:查找列,参数2是:范围,参数3是:查找的 ...

  8. php四个常用类封装

    这4个类分别是Mysql类. 分页类.缩略图类.上传类. Mysql类 <?php /** * Mysql类 */ class Mysql{ private static $link = nul ...

  9. LeetCode - 766. Toeplitz Matrix

    A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now given ...

  10. win10图片恢复默认照片查看器

    文件名: win10图片恢复默认照片查看器.reg 双击该文件导入到注册表 Windows Registry Editor Version 5.00 ; Change Extension's File ...