当前位置: 首页 > wzjs >正文

丹阳做公司网站的网站域名绑定

丹阳做公司网站的,网站域名绑定,平台企业是什么意思,旅游网页模板图片目录 C. Sigma Problem D. Another Sigma Problem C. Sigma Problem 容斥。所有都先不取模,每个数出现 n - 1次,先算出不取模的答案。 接下来找出哪些对之和超出了 1e8,统计这样的对的个数,再拿之前的答案减掉 个数 * 1e8 只需要…

目录

        C. Sigma Problem

        D. Another Sigma Problem 


 

 

 

C. Sigma Problem

 

        容斥。所有都先不取模,每个数出现 n - 1次,先算出不取模的答案。

        接下来找出哪些对之和超出了 1e8,统计这样的对的个数,再拿之前的答案减掉 个数 * 1e8

        只需要用二分就可以查找了, lower_bound(a + i + 1, a + n + 1, mod - a[i]) - a 的查找范围:

        [ i + 1, n ]

 

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 3e5 + 5, INF = 1e18, mod = 1e8;int T, n, cnt, tot, ans, a[N];
string s;signed main()
{cin >> n;for (int i = 1; i <= n; i ++){cin >> a[i];ans += a[i];}ans *= (n - 1);sort(a + 1, a + n + 1);for (int i = 1; i <= n; i ++){int pos = lower_bound(a + i + 1, a + n + 1, mod - a[i]) - a;ans -= (n + 1 - pos) * mod;}cout << ans;return 0;
}

 

若数组 a 的下标从 1 开始,要在闭区间 [l, r](其中 l 和 r 分别代表左右端点的下标)内查找第一个大于或等于 x 的元素,lower_bound 的正确使用方式如下:int pos = lower_bound(a + l, a + r + 1, x) - a;

 

 

 

 

 

D. Another Sigma Problem 

 

        每一个 ai 作为 Ai 共 n - i 次,作为 Aj 共 i - 1 次,按每个数算贡献。

        g 数组一定要每一个都取模

        

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 5, INF = 1e18, mod = 998244353;int T, n, cnt, ans, a[N], c[N], d[N], g[N];
string s;int fpow(int a, int b)
{int res = 1;while (b){if (b & 1)res = res * a % mod;a = a * a % mod;b >>= 1;}return res;
}signed main()
{cin >> n;for (int i = 1; i <= n; i ++){cin >> a[i];s = to_string(a[i]);int len = s.length();c[i] = len;}g[n] = 0;for (int i = 1; i <= n; i ++)d[i] = fpow(10, c[i] % ( mod - 1));for (int i = n - 1; i >= 1; i --)g[i] = (g[i + 1] + d[i + 1]) % mod;for (int i = 1; i <= n; i ++){ans = (ans + a[i] * (i - 1) % mod) % mod;ans = (ans + a[i] * g[i] % mod) % mod;}cout << ans;return 0;
}
http://www.dtcms.com/wzjs/583509.html

相关文章:

  • 学校网站建设价格网站与网页之间的区别是什么
  • 做网站需要工具济南网站建设与优化
  • 织梦学校网站wordpress自动保存远程图片
  • 维修网站源码电子商务网站系统开发
  • 兰州网站建设推荐q479185700顶上建站之星安装说明
  • 来宾网站seojsp网站建设项目实战课后
  • 怎样做农村电商网站产品推广方式都有哪些
  • iis中怎样配置网站绑定wordpress打包ios+app
  • 网站建设客户需要提供什么科目企业网站可以备案几个
  • app手机网站制作wordpress中home page
  • 深圳建站哪家专业天津公司网站
  • 做最好的网站新新网页源代码快捷键
  • 网站菜单代码中国建设银行甘肃省分行 官方网站
  • 免费做国际贸易的网站中国万网域名注册价格
  • 全屏 网站 代码区块链开源平台
  • 衡阳企业网站建设价格dedecms做资源下载网站
  • 嘉兴市建设官方网站千库网怎么样
  • 网站图片最大尺寸网上服务厅
  • 聊城做网站的公司咨询英文网站建设方案 PPT
  • 电商网站建设 平台上传网站中ftp地址写什么
  • 哪里制作企业网站网站ip访问做图表
  • 济南品牌网站建设公司网站功能板块
  • 网站建设教程信赖湖南岚鸿点 赞做h5动画网站
  • 创建网站超链接分销系统模式
  • 做设计网站关键词推广效果分析
  • 110平米三室一厅简装图片seo学院
  • 快速网站排名wordpress猜你喜欢插件
  • 设计师做私单网站的做网站公司
  • 移动网站建设公司wordpress画廊怎么用
  • 营销型网站建设评价个人网站备案怎么写