传送门

出题人说正解为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. 资源查找器PathMatchingResourcePatternResolver的使用

    资源查找器PathMatchingResourcePatternResolver的使用 PathMatchingResourcePatternResolver是一个Ant通配符模式的Resource查 ...

  2. ifconfig 中的 eth0 eth0:1 eth0.1 与 lo

    1. eth0 eth0:1 eth0.1 eth0 eth0:1 和eth0.1三者的关系对应于物理网卡.子网卡.虚拟VLAN网卡的关系:物理网卡:物理网卡这里指的是服务器上实际的网络接口设备,这里 ...

  3. C# SQLite数据库

    在客户端配置文件<configuration>节点下,添加: <connectionStrings> <add name="localdb" conn ...

  4. store.state

    https://blog.csdn.net/qq_38658567/article/details/82847758

  5. is not in the sudoers file解决方法

    用sudo时提示"xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用户名,也就是你的用户名没有权 ...

  6. 机器学习 —— 深度学习 —— 基于DAGNN的MNIST NET

    DAGNN 是Directed acyclic graph neural network 缩写,也就有向图非循环神经网络.我使用的是由MatConvNet 提供的DAGNN API.选择这套API作为 ...

  7. 腾讯云云机安装dockers

    云机的配置 首先更新一下源(更新前一直装不了) 下载dockers-ce(社区版) 启动dockers服务 使用hello-world进行测试(由于本地没有hello-world这个镜像,所以dock ...

  8. Spring-boot(二)--thymeleaf

    @Controller @RequestMapping("/") public class MessageController { private final MessageRep ...

  9. 解决vue单页路由跳转后scrollTop的问题

    作为vue的初级使用者,在开发过程中遇到的坑太多了.在看页面的时候发现了页面滚动的问题,当一个页面滚动了,点击页面上的路由调到下一个页面时,跳转后的页面也是滚动的,滚动条并不是在页面的顶部 在我们写路 ...

  10. Java语言基础之方法的设计

    开发遵循原则之一: DRY原则:Don't Repeat Yourself(不要重复你自己的代码) 原因:重复意味着维护成本的增大 public static void main(String[] a ...