Balls Rearrangement(HDU)】的更多相关文章

Problem Description Bob has N balls and A boxes. He numbers the balls from 0 to N-1, and numbers the boxes from 0 to A-1. To find the balls easily, he puts the ball numbered x into the box numbered a if x = a mod A.   Some day Bob buys B new boxes, a…
以前好像是在UVa上貌似做过类似的,mod的剩余,今天比赛的时候受baofeng指点,完成了此道题 此题题意:求sum(|i%A-i%B|)(0<i<N-1) A.B的循环节不同时,会有重叠,重叠后的区间里的数的值相等(可以证明,这里不给出了),然后压缩区间端点值,直接求区间和即可 #include <iostream> #include <stdio.h> #include <string.h> #include <math.h> #inclu…
Balls Rearrangement Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 25    Accepted Submission(s): 8 Problem Description Bob has N balls and A boxes. He numbers the balls from 0 to N-1, and numbe…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5391 Problem Description Tina Town is a friendly place. People there care about each other. Tina has a ball called zball. Zball time times )-th day. Tina want to know its size on the (n-)-th day mo…
Problem Description 有N个比赛队(<=N<=),编号依次为1,,,....,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前.现在请你编程序确定排名. Input 输入有若干组,每组中的第一行为二个数N(<=N<=),M:其中N表示队伍的个数,M表示接着有M行的输入数据.接下来的M行数据中,每行也有两个整数P1,P2表示即P…
http://acm.hdu.edu.cn/showproblem.php?pid=4710 [code]: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; #define N 1000151 ]; ]; ]; ]; ; int lowbit(int i) { return i&-i; } void add(i…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4611 题意:给你一个N.A.B,要你求 AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cstdlib> #include <cmath> #include <vector> #include…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5933 题意:长度为nn的数组: a_1, a_2, \cdotsa​1​​,a​2​​,⋯, 每次操作要么可以merge两个相邻的数为一个, 值为两个数的和; 要么可以把一个数分裂成两个, 两个数的和为原数. 用最少的操作把数组变换成长度为KK且所有数值相等的数组, 无解输出-1−1. 读错题了啊-以为是任意merge,题意是相邻的merge. 分情况讨论,每次判断当前点是比avg大还是小,如果大的…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1042 Problem Description Given an integer N( ≤ N ≤ ), your task is to calculate N! Input One N in one line, process to the end of file. Output For each N, output N! in one line. Sample Input Sample…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5234 Problem Description Today is Gorwin’s birthday. So her mother want to realize her a wish. Gorwin says that she wants to eat many cakes. Thus, her mother takes her to a cake garden. The garden…