博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDOJ 4944 FSF’s game
阅读量:5770 次
发布时间:2019-06-18

本文共 2133 字,大约阅读时间需要 7 分钟。

不明真相的补一发。。。

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
 

#include 
#include
#include
#include
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

转载地址:http://wniux.baihongyu.com/

你可能感兴趣的文章
SQL注入漏洞全接触--进阶篇
查看>>
电商应用脚本开发遇到问题和处理
查看>>
商教助手!解析夏普液晶高清宽屏投影机系列
查看>>
中国平安增持华夏幸福5.69%股权 看好长期战略协同
查看>>
云南去年有望实现151万贫困人口净脱贫
查看>>
Java架构师面试题系列整理(大全)
查看>>
延伸产业链 中国产粮大省向“精深”问发展
查看>>
消费贷用户70%月收入低于5000元 80、90后是主要人群
查看>>
2018年内蒙古外贸首次突破1000亿元
查看>>
为什么主流APP的推荐总能符合你口味?推荐系统了解一下
查看>>
完整的大数据知识体系,大数据学习路线图
查看>>
CTOR有助于BCH石墨烯技术更上一层楼
查看>>
被遗忘的CSS
查看>>
Webpack中的sourcemap以及如何在生产和开发环境中合理的设置sourcemap的类型
查看>>
做完小程序项目、老板给我加了6k薪资~
查看>>
面试必备:LinkedList源码解析(JDK8)
查看>>
java工程师linux命令,这篇文章就够了
查看>>
翻译 | 玩转 React 表单 —— Refs 的运用
查看>>
关于React生命周期的学习
查看>>
webpack雪碧图生成
查看>>