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. JS 实现可停顿的垂直滚动
  2. 【廖雪峰python入门笔记】break和continue
  3. loadrunner中自定义查找并替换函数
  4. 02_记录学生相关数据,输出平均分数
  5. python包导入细节_python循环导入是一个实现细节吗?
  6. dojo中的dojo/dom-construct
  7. WordPress 添加网页图标
  8. hihocoder第229周:最大连续字母个数
  9. 使用JavaScript判断用户是否为手机设备
  10. IdentityServer4学习及简单使用
  11. AR引擎vuforia源码分析、中文注释(2)用手势控制来与模型简单交互
  12. C. Removing Smallest Multiples codeforces 1734C
  13. HTML网页获取当前定位经纬度/地理位置定位/百度定位/高德定位
  14. 【JIS-CTF靶场搭建及解题思路】
  15. 云栖大会:两万人参会 十大亮点抢先看
  16. 六派巨量转移技术概述
  17. ▩Dart-生成器函数
  18. C# 调用微软自带SpeechSDK 实现文字转语音
  19. 鸿蒙升级包7g,首个华为鸿蒙2.0续航测试来了!实打实10%提升
  20. 谈谈对Spring IOC(控制反转)的理解

热门文章

  1. 什么是软件项目管理中的WBS?
  2. H265 Vs VP9
  3. 计算几何小结 我对计算几何的理解以及叉积和点积
  4. python正则匹配日期2019-03-11_正则表达式验证日期(多种日期格式)——转载
  5. 供应链管理-降低产品复杂度
  6. 书籍精品Android篇,拿好赶紧收藏
  7. win10 远程桌面连接设置
  8. mbedtls基础及其应用
  9. 第一篇:初识信息系统监理工程师
  10. 【新书推荐】【2019】电磁理论和等离子体电子学的工程师手册