http://blog.csdn.net/keshuai19940722/article/details/38519681

不明真相的补一发。。。

FSF’s game

Time Limit: 9000/4500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 448    Accepted Submission(s): 215

Problem Description
FSF has programmed a game.
In this game, players need to divide a rectangle into several same squares.
The length and width of rectangles are integer, and of course the side length of squares are integer.

After division, players can get some coins.
If players successfully divide a AxB rectangle(length: A, width: B) into KxK squares(side length: K), they can get A*B/ gcd(A/K,B/K) gold coins.
In a level, you can’t get coins twice with same method. 
(For example, You can get 6 coins from 2x2(A=2,B=2) rectangle. When K=1, A*B/gcd(A/K,B/K)=2; When K=2, A*B/gcd(A/K,B/K)=4; 2+4=6; )

There are N*(N+1)/2 levels in this game, and every level is an unique rectangle. (1x1 , 2x1, 2x2, 3x1, ..., Nx(N-1), NxN)

FSF has played this game for a long time, and he finally gets all the coins in the game.
Unfortunately ,he uses an UNSIGNED 32-BIT INTEGER variable to count the number of coins.
This variable may overflow.
We want to know what the variable will be.
(In other words, the number of coins mod 2^32)

Input
There are multiply test cases.

The first line contains an integer T(T<=500000), the number of test cases

Each of the next T lines contain an integer N(N<=500000).

Output
Output a single line for each test case.

For each test case, you should output "Case #C: ". first, where C indicates the case number and counts from 1.

Then output the answer, the value of that UNSIGNED 32-BIT INTEGER variable.

Sample Input
3 1 3 100
Sample Output
Case #1: 1 Case #2: 30 Case #3: 15662489

Hint

In the second test case, there are six levels(1x1,1x2,1x3,2x2,2x3,3x3) Here is the details for this game: 1x1: 1(K=1); 1x2: 2(K=1); 1x3: 3(K=1); 2x2: 2(K=1), 4(K=2); 2x3: 6(K=1); 3x3: 3(K=1), 9(K=3); 1+2+3+2+4+6+3+9=30

Author
UESTC
Source
2014 Multi-University Training Contest 7
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>using namespace std;typedef long long int LL;const int maxn=500050;
const LL mod=1LL<<32;LL f[maxn],s[maxn];void init()
{for(int i=1;i<maxn;i++){for(int k=1;k*i<maxn;k++){f[i*k]+=(1LL+k)*k/2;f[i*k]%=mod;}f[i]=f[i]*i;f[i]%=mod;}for(int i=1;i<maxn;i++){s[i]=(f[i]+s[i-1])%mod;}
}int main()
{init();int T_T,cas=1;scanf("%d",&T_T);while(T_T--){int x;scanf("%d",&x);printf("Case #%d: %lld\n",cas++,s[x]);}return 0;
}

HDOJ 4944 FSF’s game相关推荐

  1. 并查集 HDOJ 1232 畅通工程

    题目传送门 1 /* 2 并查集(Union-Find)裸题 3 并查集三个函数:初始化Init,寻找根节点Find,连通Union 4 考察:连通边数问题 5 */ 6 #include <c ...

  2. 【HDOJ 3652】B-number

    [HDOJ 3652]B-number 给一整数n 找<=n的整数中能被13整除且含有13的 数位dp 记忆化! . 一入记忆化深似海. ..再也不想用递推了...发现真的非常好想 仅仅要保证满 ...

  3. 【HDOJ】4343 Interval query

    最大不相交集合的数量. 思路是dp[i][j]表示已经有i个不相交集合下一个不相交集合的最右边界. 离散化后,通过贪心解. 1 /* 4343 */ 2 #include <iostream&g ...

  4. 【HDOJ】4579 Random Walk

    1. 题目描述 一个人沿着一条长度为n个链行走,给出了每秒钟由i到j的概率($i,j \in [1,n]$).求从1开始走到n个时间的期望. 2. 基本思路 显然是个DP.公式推导也相当容易.不妨设$ ...

  5. AC自动机 HDOJ 5384 Danganronpa

    题目传送门 1 /* 2 题意:多个文本串,多个模式串在每个文本串出现的次数 3 AC自动机:这就是一道模板题,杭电有道类似的题目 4 */ 5 /************************** ...

  6. 构造 HDOJ 5400 Arithmetic Sequence

    题目传送门 题意:问有多少个区间,其中存在j使得ai + d1 == ai+1(i<j) && ai + d2 == ai+1 (i>j) 构造:用c1[i], c2[i] ...

  7. Kruskal HDOJ 1233 还是畅通工程

    题目传送门 1 /* 2 最小生成树之kruskal算法--并查集(数据结构)实现 3 建立一个结构体,记录两点和它们的距离,依照距离升序排序 4 不连通就累加距离,即为最小生成树的长度 5 */ 6 ...

  8. HDOJ 5373 The shortest problem 【数论】

    HDOJ 5373 The shortest problem [数论] 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5373 题目给一个初始数据和重复 ...

  9. AC解 - Phone List(HDOJ#1671) 前缀树的一个应用

    原题:http://acm.hdu.edu.cn/showproblem.php?pid=1671 Time Limit: 3000/1000 MS (Java/Others)    Memory L ...

  10. 【hdoj】3007 Buried memory 【计算几何--最小圆覆盖】

    传送门:Buried memory 苍天饶过谁,第三次在hdoj上 交计算几何的题了,没一次是AC的. ┭┮﹏┭┮都是模板题啊,我都是抄板子的啊,为什么会这样,我怎么这么菜. 题意: 求最小圆覆盖 的 ...

最新文章

  1. php 实现查询百度排名,PHP实现获取百度top50的搜索排行关键字
  2. 量化策略研究员 - 工具篇
  3. 笑话(15) 这是地球
  4. Angular SPA基于Ocelot API网关与IdentityServer4的身份认证与授权
  5. 旅游系统_数字洛江智慧旅游系统助力提升旅游安全水平
  6. 前端学习(1927)vue之电商管理系统电商系统之美化一层循环的UI结构for循环渲染第三层结构
  7. Xcode 添加 background modes、Associated Domains 等设置项
  8. vba ado返回集合_VBA利用IE,抓取深市股票涨跌数据
  9. Chrome驱动对应chrome浏览器版本
  10. 怎样在mac系统里将文件拷贝到移动硬盘教程
  11. openwrt修改默认网关地址_命令下配置ip地址
  12. ICP经营许可证办理流程有哪些?
  13. 合肥工业大学机器人技术实验五十六题
  14. wheel安装+使用wheel安装第三方库+临时换源安装和永久换源安装
  15. node 文字生成图片
  16. wp8手机用得真憋屈
  17. 如何使用js添加html标签
  18. 键盘输入10个正整数,先打印输出奇数,再输出偶数
  19. 冲顶大会、HQ火了,该如何打造一款在线答题App呢?
  20. 微信支付接口调用记录

热门文章

  1. ipadpro画流程图_Paper 推出适用于快速制作流程图的 Think 套件
  2. 软件项目管理题目汇总
  3. yasm,nasm的关系
  4. 二进制 八进制 十进制 十六进制 相互转化法
  5. 深度学习——反向传播(Backpropagation)
  6. 截至20161210沪市股票代码和名称
  7. FANUC 工业机器人编程与联网
  8. 串口485接法图_史上最全的RS485串口通讯的详细讲解
  9. [摘]研究方法 - 实证研究
  10. swift plm物料管理模块中的变更管理介绍