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头奶牛,要在喂奶截止时间前给他喂奶并得到相应的含量的牛奶. 一开始的想法就是挑选截止日期的 ...
随机推荐
- Mac008--快捷键
Mac008--快捷键 来自于百度经验:https://jingyan.baidu.com/article/08b6a591aac09614a909224f.html 快捷键图示 基本的快捷键 Com ...
- Angular 输入中的禁止特定输入值--Validator 与 Directive 实现
1 前言 最近在项目中涉及表单的情况下,需要对用户输入进行过滤,比如填写用户名的时候不可以使用空格或者特殊符号,这里有几个解决方法: 使用 Angular 的正则同步验证器 使用 RxJS对输入的值进 ...
- [Linux] 015 用户管理命令
1. 用户管理命令:useradd 命令名称:useradd 命令所在路径:/bin/sbin/useradd 执行权限:root 语法:useradd 用户名 功能描述:添加新用户 范例: $use ...
- [Linux] 009 链接命令
链接命令:ln 命令名称:ln 命令英文原意:link 命令所在路径:/bin/ln 执行权限:所有用户 语法:ln -s [原文件] [目标文件] 功能描述:生成链接文件 范例: 创建文件 /etc ...
- [Bzoj1047][HAOI2007]理想的正方形(ST表)
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1047 题目虽然有一个n的限制,但求二维区间最值首先想到的还是RMQ,但是如果按照往常RM ...
- mongodb的有关操作
mongodb的几种启动方法 https://www.cnblogs.com/LLBFWH/articles/11013791.html MongoDB 之 你得知道MongoDB是个什么鬼 Mong ...
- 源码分析--HashSet(JDK1.8)
HashSet为无序不可重复集合.底层几乎全部借助HashMap实现,比较简单.本篇简要分析一下HashSet源码. 首先是成员变量: 1.真正保存数据的HashMap实例 private trans ...
- Introduction to Sound Programming with ALSA
ALSA stands for the Advanced Linux Sound Architecture. It consists of a set of kernel drivers, an ap ...
- Oracle 反键索引/反向索引
反键索引又叫反向索引,不是用来加速数据访问的,而是为了均衡IO,解决热块而设计的比如数据这样: 1000001 1000002 1000005 1000006 在普通索引中会出现在一个叶子上,如果部门 ...
- Sass函数--列表函数append
append() 函数是用来将某个值插入到列表中,并且处于最末位. >> append(10px 20px ,30px) (10px 20px 30px) >> append( ...