soj#552 449E Jzzhu and Squares
分析
https://www.cnblogs.com/Memory-of-winter/p/11209128.html
代码
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6+;
const int mod = 1e9+;
int phi[N+],is[N+],a[N+],b[N+],c[N+],n,m,t;
signed main(){
int i,j,k,x=,y=;
for(i=;i<=N;i++)phi[i]=i;
for(i=;i<=N;i++)
if(!is[i])for(j=i;j<=N;j+=i)
is[j]=,phi[j]=phi[j]/i*(i-);
for(i=;i<=N;i++){
x=(x+*i+)%mod;
y=(y+*i*i)%mod;
a[i]=((i*i%mod*i%mod-x*i%mod+y)%mod+mod)%mod;
}
for(i=;i<=N;i++)
for(j=i;j<=N;j+=i)
a[j]=(a[j]+2ll*i*phi[j/i]%mod)%mod;
for(i=;i<=N;i++){
b[i]=(b[i-]+a[i]*i%mod)%mod;
c[i]=(c[i-]+a[i]*i%mod*i%mod)%mod;
a[i]=(a[i]+a[i-])%mod;
}
scanf("%lld",&t);
while(t--){
scanf("%lld%lld",&n,&m);
n++,m++;
int x=min(n,m);
printf("%lld\n",((n*m%mod*a[x]%mod-(n+m)*b[x]%mod+c[x])%mod+mod)%mod);
}
return ;
}
soj#552 449E Jzzhu and Squares的更多相关文章
- CF449E Jzzhu and Squares
题目大意:有一个$n\times m$的方格图,求其中所有的格点正方形完整包含的小方格个数,多组询问.$n,m\leqslant 10^6$ 题解:令$n\leqslant m$.有一个显然的式子:$ ...
- CF449 (Div. 1简单题解)
A .Jzzhu and Chocolate pro:现在给定一个大小为N*M的巧克力,让你横着或者竖着切K刀,都是切的整数大小,而且不能切在相同的地方,求最大化其中最小的块. (N,M,K<1 ...
- Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)
主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...
- Codeforces Round #257 (Div. 2) C. Jzzhu and Chocolate
C. Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standa ...
- cf 450c Jzzhu and Chocolate
Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces 450C:Jzzhu and Chocolate(贪心)
C. Jzzhu and Chocolate time limit per test: 1 seconds memory limit per test: 256 megabytes input: st ...
- [LeetCode] Word Squares 单词平方
Given a set of words (without duplicates), find all word squares you can build from them. A sequence ...
- 卡通图像变形算法(Moving Least Squares)附源码
本文介绍一种利用移动最小二乘法来实现图像变形的方法,该方法由用户指定图像中的控制点,并通过拖拽控制点来驱动图像变形.假设p为原图像中控制点的位置,q为拖拽后控制点的位置,我们利用移动最小二乘法来为原图 ...
- 【贪心】SOJ 13983
SOJ 13983. Milk Scheduling 这是比赛题,还是作死的我最讨厌的英文题,题目大意就是有n头奶牛,要在喂奶截止时间前给他喂奶并得到相应的含量的牛奶. 一开始的想法就是挑选截止日期的 ...
随机推荐
- Git009--分支管理&创建与合并分支
Git--分支管理&创建与合并分支 一.分支管理 本文来自于:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578 ...
- sql server 2008查询时报错,消息:8155,没有为'a'的列2指向任何列
解决方法1: 关掉Sql Server再打开, 重新查询 解决方法2: select T.* from( select row_number() over(order by age desc) a ...
- 01 - Jmeter4.x环境安装以及简单使用
Jmeter 介绍 Apache JMeter应用程序是开源软件,旨在为负载测试功能行为和测量性能的100%纯Java应用程序.它最初是为测试Web应用程序而设计的,但后来扩展到其他测试功能 常用压力 ...
- spring的4种事务特性,4种隔离级别,7种传播行为
spring事务: 什么是事务: 事务逻辑上的一组操作,组成这组操作的各个逻辑单元,要么一起成功,要么一起失败. 事务特性(4种): 原子性 (atomicity):强调事务的不可分割. 一致性 (c ...
- 61-python基础-python3-格式化浮点数方法-%e、%f、%g
1-%e是用科学记数法计数: %f是按指定精确格式化浮点数(默认保留6位): %g是根据数值的大小采用e或%f. 2-%f可以按长度和精度格式化浮点数,如%a.bf,a表示浮点数的长度,b表示浮点数小 ...
- 56-python基础-python3-集合-新建集合
集合对象是一组无序排列的可哈希的值,集合成员可以做字典中的键. 集合支持用in和not in操作符检查成员. 由len()内建函数得到集合的基数(大小). 用 for 循环迭代集合的成员. 但是因为集 ...
- break和continue能否跳出函数
int func() { printf("In func, before continue.\n"); // continue; break; printf("In fu ...
- C# 一个网站
http://www.aizhengli.com/aspnet-mvc5/6/aspnet-mvc5-member-user-register.html
- Linux ssh黄金参数
Linux ssh黄金参数 命令: -o ConnectionAttempts= -o PasswordAuthentication=no -o StrictHostKeyChecking=no cp ...
- swagger集成到springBoot 项目中
1 pom 文件加包依赖 <dependency> <groupId>io.springfox</groupId> <artifactId>spring ...