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头奶牛,要在喂奶截止时间前给他喂奶并得到相应的含量的牛奶. 一开始的想法就是挑选截止日期的 ...
随机推荐
- 爬虫之requests 请求
1.发送不同的请求 import requests r = requests.get('https://www.baidu.com/') r = requests.post('http://httpb ...
- Requests爬取网页的编码问题
Requests爬取网页的编码问题 import requests from requests import exceptions def getHtml(): try: r=requests.get ...
- anaconda安装教程、管理虚拟环境
原文链接:https://blog.csdn.net/ITLearnHall/article/details/81708148 另可参看文章:https://www.cnblogs.com/jonin ...
- python学习第五天流程控制分支if和循环while
所有的逻辑结构围绕分支和循环进行,比如登陆注册,支付成功与否等等,下面讲述分支if用法和while用法 if age>30: print("www.96net.com.cn" ...
- C# 使用Epplus导出数据到Excel
简介:Epplus是一个使用Open Office XML(Xlsx)文件格式,能读写Excel 2007/2010文件的开源组件 功效:支持对excel文档的汇入汇出,图表(excel自带的图表基本 ...
- JVM(15)之 类加载器
开发十年,就只剩下这套架构体系了! >>> 今天我们将类加载机制5个阶段中的第一个阶段,加载,又叫做装载.为了便于阅读,以下都叫做装载. 装载的第一步就是要获得二进制的字节 ...
- hud2243 考研路茫茫——单词情结
考研路茫茫--单词情结 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem ...
- iviewUI框架,使用table表格内render下拉框select被遮盖问题
使用props:{ transfer:true },即可 1.原本代码:
- ajax中的application/x-www-form-urlencoded中的使用[转]
一,HTTP上传的基本知识 在Form元素的语法中,EncType表明提交数据的格式 用 Enctype 属性指定将数据回发到服务器时浏览器使用的编码类型.下边是说明: application/x-w ...
- java写文件UTF-8格式
String fileName = dir + File.separator + date + File.separator + (file.list().length + 1) + ".t ...