CSU1803——2016(思路)
来源:互联网 发布:淘宝直播大v通道 编辑:程序博客网 时间:2024/05/01 11:15
1803: 2016
Time Limit: 5 Sec Memory Limit: 128 Mb Submitted: 1201 Solved: 689Description
给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量:
1. 1≤a≤n,1≤b≤m;
2. a×b 是 2016 的倍数。
Input
输入包含不超过 30 组数据。
每组数据包含两个整数 n,m (1≤n,m≤109).
Output
对于每组数据,输出一个整数表示满足条件的数量。
Sample Input
32 632016 20161000000000 1000000000
Sample Output
1305767523146895502644
Hint
Source
湖南省第十二届大学生计算机程序设计竞赛思路:a*b%2016==0 那么(a%2016) * (b%2016)==0
也就是说,n和m中各有多少模2016的余数满足i*j%2016==0,这些数量相乘即可
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <stack>
using namespace std;
typedef long long ll;
#define PI 3.1415926535897932
#define E 2.718281828459045
#define INF 0xffffffff//0x3f3f3f3f
#define mod 1000000007
const int MOD=1e9+7;
const int M=1005;
int n,m;
int a[2016],b[2016];
void init(int n,int m)
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
for(int i=1; i<=2016; i++)
{
a[i]=n/2016;
}
for(int i=1; i<=n%2016; i++)
{
a[i]++;
}
for(int i=1; i<=2016; i++)
{
b[i]=m/2016;
}
for(int i=1; i<=m%2016; i++)
{
b[i]++;
}
}
int main()
{
int i,j,k,t;
while(~scanf("%d%d",&n,&m))
{
/*for(i=1; i*i<=2016; i++)
if(2016%i==0)
printf("%d %d\n",i,2016/i);*/
init(n,m);
ll ans=0;
for(i=1; i<=2016; i++)
for(j=1; j<=2016; j++)
if((i*j)%2016==0)
{
ans+=(ll)a[i]*b[j];
//printf("%d %d\n",i,j);
}
printf("%I64d\n",ans);
}
return 0;
}
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <stack>
using namespace std;
typedef long long ll;
#define PI 3.1415926535897932
#define E 2.718281828459045
#define INF 0xffffffff//0x3f3f3f3f
#define mod 1000000007
const int MOD=1e9+7;
const int M=1005;
int n,m;
int a[2016],b[2016];
void init(int n,int m)
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
for(int i=1; i<=2016; i++)
{
a[i]=n/2016;
}
for(int i=1; i<=n%2016; i++)
{
a[i]++;
}
for(int i=1; i<=2016; i++)
{
b[i]=m/2016;
}
for(int i=1; i<=m%2016; i++)
{
b[i]++;
}
}
int main()
{
int i,j,k,t;
while(~scanf("%d%d",&n,&m))
{
/*for(i=1; i*i<=2016; i++)
if(2016%i==0)
printf("%d %d\n",i,2016/i);*/
init(n,m);
ll ans=0;
for(i=1; i<=2016; i++)
for(j=1; j<=2016; j++)
if((i*j)%2016==0)
{
ans+=(ll)a[i]*b[j];
//printf("%d %d\n",i,j);
}
printf("%I64d\n",ans);
}
return 0;
}
0 0
- CSU1803——2016(思路)
- csu1803——2016(数学)
- CSU1803 2016 同余
- CSU1803 2016(同余)
- 2016-CSU1803(同余公式)
- 2016湖南省省赛A-2016(CSU1803)
- csu1803-2016 湖南省大学生第十二届程序设计竞赛
- CSU1803: 2016(湖南省第十二届大学生计算机程序设计竞赛A)
- 暴力脑洞-CSU1803
- 开发思路—30/7/2016
- 【思路】超级传送带——我的程序思路
- 2011年终总结——思路
- 刷网页技术—思路
- 三子棋—思路分析+代码
- 程序员的赚钱思路——分割
- 规则匹配引擎——思路1
- 规则匹配引擎——思路2
- 规则匹配引擎——思路3
- JVM 参数介绍
- React-Native权限管理工具类
- Oracle占用8080端口问题的解决
- 广告位标识符
- 详解PHP设置定时任务的实现方法
- CSU1803——2016(思路)
- SQL SERVER【非域环境】同步复制(对等)之搭建篇
- maven项目 启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- Linux下的lds链接脚本基础
- 机顶盒CA解密流程
- mysql中int、bigint、smallint 和 tinyint的区别详细介绍
- 一键设置L2TP脚本-Ubuntu14.04LTS
- 第六单元
- 工厂模式