Parco_Love_gcd
出题人说正解为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的更多相关文章
随机推荐
- fiddler抓包url有乱码
fiddler抓包url有乱码: 解决具体步骤: 注册表:regedit HKEY_CURRENT_USER\Software\Microsoft\Fiddler2 1.打开注册表,regedit ...
- 微信公众号平台上传文件返回错误代码:40005 invalid file type
错误原因:文件类型(后缀名)不符合要求. 具体到笔者的情况是:在将 MultipartFile 类型转换为File 类型时,方法 File.createTempFile("filename& ...
- Zookeeper —— 一致性协议
一致性协议 为了解决分布式系统中存在的一致性问题,提出了一些经典的一致性协议和算法. 其中著名的有:二阶段提交协议.三阶段提交协议和 Paxos 算法. 2PC 与 3PC 2PC 2pc(Two-P ...
- Android Studio编译报错“java.lang.OutOfMemoryError: GC overhead limit exceeded
1.在build.gradle添加脚本指定编译堆内存 如果在整个工程中生效,则在build.gradle中增加如下配置: android { .............. dexOptions { i ...
- Linux shell去除字符串中所有空格
Linux shell去除字符串中所有空格 echo $VAR | sed 's/ //g'
- php 慢配置文件
[root@localhost etc]# cat php-fpm.conf[global]pid = /usr/local/php/var/run/php-fpm.piderror_log = /u ...
- python3 使用ldap3来作为django认证后台
首先先使用ldap3测试ldap服务是否正常 我们先要拿到dc的数据,以及连接ldap的密码,还有搜索的字段(search_filter), 一般来说search_filter 这个是从负责ldap运 ...
- SwipeToLoadLayout
SwipeToLoadLayout SwipeToLoadLayout is a reusable pull-to-refresh and pull-to-load-more widget. Supp ...
- LeetCode - 503. Next Greater Element II
Given a circular array (the next element of the last element is the first element of the array), pri ...
- thinphp5框架遇到 mkdir() Permission denied 解决办法
网站重装 直接复制本地程序文件 里面数据库链接信息要改成线上的 然后mysql apache 等都没有动 运行后出现错误 mkdir() Permission denied 这是由于runtime目录 ...