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. POM报错Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from

    解决方式一:   1.查看.m2\repository\org\apache\maven\plugins\maven-resources-plugin\下maven-resources-plugin- ...

  2. eclipse快捷键,移动和复制一段代码

    移动代码:alt+上或下箭头 复制加移动代码:ctrl + alt + 上或下箭头

  3. 转-sql之left join、right join、inner join的区别

    left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录 right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录inner join(等值连接) 只 ...

  4. AJPFX简述JavaStringBuffer方法

    以下是StringBuffer类支持的主要方法: 序号 方法描述 1 public StringBuffer append(String s)将指定的字符串追加到此字符序列. 2 public Str ...

  5. UVa OJ 458

     The Decoder  Write a complete program that will correctly decode a set of characters into a valid m ...

  6. 使用NPOI操作Excel文件及其日期处理

    工作中经常遇到需要读取或导出Excel文件的情况,而NPOI是目前最宜用.效率最高的操作的Office(不只是Excel哟)文件的组件,使用方便,不详细说明了. Excel工作表约定:整个Excel表 ...

  7. Oracle体系结构总览

    第一篇 Oracle架构总览 先让我们来看一张图   这张就是Oracle 9i的架构全图.看上去,很繁杂.是的,是这样的.现在让我们来梳理一下: 一.数据库.表空间.数据文件 1.数据库 数据库是数 ...

  8. Android(java)学习笔记171:服务(service)之绑定服务调用服务里面的方法

    1.绑定服务调用服务里面的方法,图解: 步骤: (1)在Activity代码里面绑定 bindService(),以bind的方式开启服务 :                     bindServ ...

  9. [Redis] 基于redis的分布式锁

    前言分布式锁一般有三种实现方式:1. 数据库乐观锁:2. 基于Redis的分布式锁:3. 基于ZooKeeper的分布式锁.本篇博客将介绍第二种方式,基于Redis实现分布式锁. 可靠性首先,为了确保 ...

  10. python实战教程之自动扫雷(自己存下来学习之用)

    3.python的第三方库win32api,win32gui,win32con,Pillow,numpy,opencv可通过 pip install --upgrade SomePackage 来进行 ...