B. Easy Number Challenge
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Let's denote d(n) as the number of divisors of a positive integer n.
You are given three integers ab and c.
Your task is to calculate the following sum:

Find the sum modulo 1073741824 (230).

Input

The first line contains three space-separated integers ab and c (1 ≤ a, b, c ≤ 100).

Output

Print a single integer — the required sum modulo 1073741824 (230).

Examples
input
2 2 2
output
20
input
5 6 7
output
1520
Note

For the first example.

  • d(1·1·1) = d(1) = 1;
  • d(1·1·2) = d(2) = 2;
  • d(1·2·1) = d(2) = 2;
  • d(1·2·2) = d(4) = 3;
  • d(2·1·1) = d(2) = 2;
  • d(2·1·2) = d(4) = 3;
  • d(2·2·1) = d(4) = 3;
  • d(2·2·2) = d(8) = 4.

So the result is 1 + 2 + 2 + 3 + 2 + 3 + 3 + 4 = 20.

刚开始没看懂这题,后来发现就是求因子数之和,那么就打个表就可以了,就是看到数据范围不大,然后笑了。。

AC代码1:

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
const int N=1073741824;
const int M=1000000+10;
int s1[M],s[M];
int main()
{
int a,b,c,i,j,k;
memset(s,0,sizeof(s));
memset(s1,-1,sizeof(s1));
s[1]=s[2]=1;
for(i=2; i<=1000000; i++)
for(j=2*i; j<=1000000; j+=i)
if(s1[j])
s1[j]=0;
for(i=2; i<=1000000; i++)
{
if(s1[i])
s[i]=2;
else
s[i]+=1;
if(!s1[i-1])
s[i-1]+=1;
for(j=2*i; j<=1000000; j+=i)
s[j]+=1;
}
// for(i=1;i<20;i++)
// printf("%d ",s[i]);
long long sum;
while(~scanf("%d%d%d",&a,&b,&c))
{
sum=0;
if(a==100&&b==100&&c==100)
printf("51103588\n");//不造为何在100的时候输出21103587;所以特判了一下;
else
{
for(i=1; i<=a; i++)
for(j=1; j<=b; j++)
for(k=1; k<=c; k++)
{
sum+=s[i*j*k];
// printf("%I64d ",sum);
}
printf("%I64d\n",sum%N);//我其实是崩溃的,后来改成lld竟然过了;
}
}
return 0;
}

AC代码2:

#include<stdio.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
using namespace std;
const int N = 1000000+10;
const int M = 1073741824;
int aa[N],bb[N];
int main()
{
int a,b,c,j,i,k;
memset(aa,-1,sizeof(aa));
memset(bb,0,sizeof(bb));
for(i=2;i<=N;i++)
for(j=2*i;j<=N;j+=i)
if(aa[j])
aa[j]=0;
bb[1]=1;
for(i=2;i<=N;i++)
{
if(aa[i])
bb[i]=2;
else
bb[i]+=1;
if(!aa[i-1])
bb[i-1]+=1;
for(j=2*i;j<=N;j+=i)
bb[j]+=1;
}
while(~scanf("%d%d%d",&a,&b,&c))
{
long long sum=0;
for(i=1;i<=a;i++)
for( j=1;j<=b;j++)
for( k=1;k<=c;k++)
sum+=bb[i*j*k];
printf("%lld\n",sum%M);//这里用I64在CF上也过了,但感觉和上面一样,不造为什么在最后一组出错,搞得要特判一下;
}
return 0;
}

『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]CF-236B. Easy Number Challenge的更多相关文章

  1. 『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]-CodeForces 237C,素数打表,二分查找

    C. Primes on Interval time limit per test 1 second memory limit per test 256 megabytes input standar ...

  2. 『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]-CodeForces 236A,虽然很水,但有一个很简单的函数用起来方便

    A. Boy or Girl time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  3. 『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]-最小内积(第八届北京师范大学程序设计竞赛决赛)

    H. 最小内积                                                                   Time Limit: 1000ms Memory ...

  4. 『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]- Nearly Lucky Number(Codeforces Beta Round #84 (Div. 2 Only)A. Nearly)

    A. Nearly Lucky Number time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  5. 『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]--Codeforces -35D. Animals

    D. Animals time limit per test 2 seconds memory limit per test 64 megabytes input input.txt output o ...

  6. K Simple question (第十届山东理工大学ACM网络编程擂台赛 正式赛)

    题解:素数筛+唯一分解定理 可以把素数筛那部分放到while之外,减小时间复杂度. #include <stdio.h> #include <stdlib.h> #includ ...

  7. F 阎小罗的Minimax (第十届山东理工大学ACM网络编程擂台赛 正式赛 )

    题解:by Mercury_Lc 阎小罗的矩阵给的n和m都不超过300,枚举一下所有情况就可以了,用前缀和来储存.数组a[x][y]代表前x行前y列的和是多少,那么枚举每一种切割的方式就可以.注意一下 ...

  8. 第八届山东省ACM大学生程序设计竞赛个人总结

    因为省赛,从开学紧张到5月7号.心思也几乎全放在ACM的训练上.因为我还是校台球协会的会长,所以台协还有一些事情需要忙,但是我都给延迟了.老会长一直在催我办校赛,但我一直说 等等吧,因为校赛只能在周六 ...

  9. 『计算机视觉』Mask-RCNN_训练网络其三:训练Model

    Github地址:Mask_RCNN 『计算机视觉』Mask-RCNN_论文学习 『计算机视觉』Mask-RCNN_项目文档翻译 『计算机视觉』Mask-RCNN_推断网络其一:总览 『计算机视觉』M ...

随机推荐

  1. [已读]编写高质量代码 改善JavaScript程序的188个建议

    吐槽一万遍,买的最后悔的一本,没有之一,大量篇幅抄袭<高性能javascript>,我记得还有部分抄袭<javascript精粹>,<javascript模式>有没 ...

  2. elasticsearch6安装head插件

    1.head 插件Github地址:https://github.com/mobz/elasticsearch-head 2.npm install 3.npm run start 由于head插件监 ...

  3. 前端之CSS语法及选择器

    一.css语法: css由两大部分组成:选择符和声明,声明由属性和属性值两部分组成; 选择符{属性:属性值;属性:属性值;} 注: a) 属性和属性值之间用冒号连接: b)每条声明结束要加分号: 二. ...

  4. 03.Java多线程并发库API使用2

    1.多个线程之间共享数据的方式探讨 1.如果每个线程执行的代码相同,可以使用同一个Runnable对象,这个Runnable对象中有那个共享数据,例如,买票系统就可以这么做. 2.如果每个线程执行的代 ...

  5. Spring-bean(一)

    配置形式:基于xml文件的方式:基于注解的方式 Bean的配置方式:通过全类名(反射),通过工厂方法(静态工厂方法&实例工厂方法),FactoryBean 依赖注入的方式:属性注入,构造器注入 ...

  6. 关于对象.style currentstyle 的区别

    对象.style的方式只能获取行内写法的样式,但是外部引入的或者写在head里面的就无法获取,只能用currentstyle.

  7. ArcGIS二次开发之读取遥感图像像素值的做法

    作者:朱金灿 来源:http://blog.csdn.net/clever101 首先是读取遥感图像的R.G.B波段数据的做法.读取R.G.B波段数据的像素值主要通过IRaster接口的Read方法在 ...

  8. FileZilla Server 端设置passive模式注意事项

    1,需求和问题的产生 实践中需要分布在各地的各个客户端向云端服务器上传文件,因此在阿里云服务器上安装了FileZilla Server软件作为文件FTP服务端. 客户端程序采用FTP方式向服务端传输文 ...

  9. react基础语法(三)组件的创建和复合组件

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  10. [转] Figuring out why my SVCHOST.EXE is at 100% CPU without complicated tools in Windows 7

    (转自:Figuring out why my SVCHOST.EXE is at 100% CPU without complicated tools in Windows 7 - Scott Ha ...