hdu4473 Exam

2024-05-14 12:48
文章标签 exam hdu4473

本文主要是介绍hdu4473 Exam,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Exam
Time Limit:10000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u
Submit  Status

Description

Rikka is a high school girl suffering seriously from Chūnibyō (the age of fourteen would either act like a know-it-all adult, or thinks they have special powers no one else has. You might google it for detailed explanation) who, unfortunately, performs badly at math courses. After scoring so poorly on her maths test, she is faced with the situation that her club would be disband if her scores keeps low.
Believe it or not, in the next exam she faces a hard problem described as follows.
Let’s denote f(x) number of ordered pairs satisfying (a * b)|x (that is, x mod (a * b) = 0) where a and b are positive integers. Given a positive integer n, Rikka is required to solve for f(1) + f(2) + . . . + f(n).
According to story development we know that Rikka scores slightly higher than average, meaning she must have solved this problem. So, how does she manage to do so?

Input

There are several test cases.
For each test case, there is a single line containing only one integer n (1 ≤ n ≤ 10 11).
Input is terminated by EOF.

Output

For each test case, output one line “Case X: Y” where X is the test case number (starting from 1) and Y is the desired answer.

Sample Input

     
1 3 6 10 15 21 28

Sample Output

     
Case 1: 1 Case 2: 7 Case 3: 25 Case 4: 53 Case 5: 95 Case 6: 161 Case 7: 246
我们可以发现,从1到n加起来,不就刚好把1-n全取到了么?这样就可以转化为a*b*c的组数,这样不就so easy了!
但还有点小细节看程序
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
__int64 mypow(__int64  x,__int64 a)//x的a次方根
{__int64 m=pow(x,1.0/a),i,j,sum;//先用系统函数把大概范围求出来!while(1){sum=1;for(j=0;j<a;j++){sum*=m;}if(sum<=x){m++;}else{break;}}while(1){sum=1;for(j=0;j<a;j++){sum*=m;}if(sum>x)//这没有=号{m--;}else{return m;}}
}
int main()
{__int64 n,i,j,k,sum,iall,jall,ni;int tcase=1;while(scanf("%I64d",&n)!=EOF){iall=mypow(n,3);jall=mypow(n,2);sum=iall;//iii这种形式的刚好是iall个for(i=1;i<=iall;i++){ni=n/i;//加快速度k=mypow(ni,2);sum+=(ni/i+k-2*i)*3;//iij的个数为ni/i-i;ijj这种形式的个数为k-i个for(j=i+1;j<=k;j++)//可以推出j小于根号下(n/i)这样速度更快{sum+=(ni/j-j)*6;}}printf("Case %d: %I64d\n",tcase++,sum);}return 0;
}


这篇关于hdu4473 Exam的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/988779

相关文章

实习四十:部署project_exam_system项目——及容器的编排

(一)安装docker、编辑daemon.json文件、安装docker-compose编排容器、启动docker 1.环境准备 [root@docker--1 ~]# rz -E   rz waiting to receive.   [root@docker--1 ~]# ls   anaconda-ks.cfg  docker.sh   [root@docker--1 ~]# source

云计算41——部署project_exam_system项目(续)

# 创建脚本,可以在java环境中运行任何的jar包或者war包   #!/bin/bash   /usr/local/jdk/bin/java -jar /java/src/*.?ar 一、思路分析 (1)nginx 1、下载镜像,将本地的dist项目的目录挂载在容器的/usr/share/nginx/html/ 2、启动容器 3、该项目是一个前后端分离的项目,并非所有的请求都是来自同一个

云计算实训41——部署project_exam_system项目(续)

# 创建脚本,可以在java环境中运行任何的jar包或者war包#!/bin/bash/usr/local/jdk/bin/java -jar /java/src/*.?ar 一、思路分析 (1)nginx 1、下载镜像,将本地的dist项目的目录挂载在容器的/usr/share/nginx/html/ 2、启动容器 3、该项目是一个前后端分离的项目,并非所有的请求都是来自同一个位置,设

使用docker部署project-exam-system(项目)

使用基础的docker指令来创建镜像,实现项目的发布 Dockerfile dockerr compose编排容器 一、使用docker部署project-exam-system(项目) 1、背景,再一台主机之内,实现容器的编排,发布考试系统 2、环境准备 (1)docker [root@docker-01 ~]# vim /etc/docker/daemon.json {

部署project_exam_system项目——及容器的编排

(一)安装docker、编辑daemon.json文件、安装docker-compose编排容器、启动docker 1.环境准备 [root@docker--1 ~]# rz -Erz waiting to receive.[root@docker--1 ~]# lsanaconda-ks.cfg docker.sh[root@docker--1 ~]# source docker.sh [

使用docker部署project-exam-system(项目)(forty day)

使用基础的docker指令来创建镜像,实现项目的发布 Dockerfile dockerr compose编排容器 一、使用docker部署project-exam-system(项目) 1、背景,再一台主机之内,实现容器的编排,发布考试系统 2、环境准备 (1)docker [root@docker-01 ~]# vim /etc/docker/daemon.json {"re

HDU 5240 E - Exam(2015 ACM-ICPC China Shanghai Metropolitan Programming Contest)

题目链接:click here~~ 【题目大意】DRD要参加考试,考试前需要ri个准备时间,考试在ei时间后开始,考试持续li时间,给出多场考试时间安排表,问能否通过所有考试? 【解题思路】不知道是不是数据水还是题目就是这样的,直接判断ri和ei输出结果居然就过了,如果在现场赛能有这样的人品就好了。。 代码: #include <stdio.h>#include <math.h>#

uva 11637 - Garbage Remembering Exam(概率)

题目链接:uva 11637 - Garbage Remembering Exam 题目大意:大白数里有很详细的题意。 解题思路:对于有序的序列来说,考虑每个位置为有效性的概率。C(2∗k

MCTS: Microsoft Windows Vista Client Configuration Study Guide: Exam 70-620

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。 http://blog.csdn.net/topmvp - topmvp In-depth preparation for Microsoft's new MCTS: Windows Vista exam With the release of Windows Vista, M

MCITP SQL Server 2005 Database Administration All-in-One Exam Guide

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。 http://blog.csdn.net/topmvp - topmvp Get complete coverage of all three Microsoft Certified IT Professional database administration exams fo