链接:https://vjudge.net/problem/UVA-1363 题意:给出n  k,当 i 属于 1~n 时 ,求解 n% i 的和 n 和 k 的范围都是 1 到 10^9; 商相同 的余数数列 是 公差为商 的 递减等差数列 应该让k / i相等的一连串k % i相加,举个例子: 100 / 34 = 2 ... 32 100 / 35 = 2 ... 30 100 / 36 = 2 ... 28 ... 100 / 50 = 2 ... 0 递减等差数列通项公式:an=a1-…
题意: 给出n, k,求 分析: 假设,则k mod (i+1) = k - (i+1)*p = k - i*p - p = k mod i - p 则对于某个区间,i∈[l, r],k/i的整数部分p相同,则其余数成等差数列,公差为-p 然后我想到了做莫比乌斯反演时候有个分块加速,在区间[i, n / (n / i)],n/i的整数部分相同,于是有了这份代码. #include <cstdio> #include <algorithm> using namespace std;…
/** 题目:Joseph's Problem 链接:https://vjudge.net/problem/UVA-1363 题意:给定n,k;求k%[1,n]的和. 思路: 没想出来,看了lrj的想法才明白. 我一开始往素数筛那种类似做法想. 想k%[1,n]的结果会有很多重复的,来想办法优化. 但没走通. 果然要往深处想. 通过观察数据发现有等差数列.直接观察很难确定具体规律:此处应该想到用式子往这个方向推导试一试. lrj想法: 设:p = k/i; 则:k%i = k-i*p; 容易想到…
#define null ""是用来将字符串清空的 #define none -1是用来当不存在这种动物时,返回-1. 其实这种做法有点多余,不过好理解一些. Home Web Board ProblemSet Standing Status Statistics   Problem J: 动物爱好者 Problem J: 动物爱好者 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 509  Solved: 376[Submit][Stat…
Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description The travel agency “Four Russians” is offering the new service for their clients. Unlike other agencies that only suggest one-way…
Problem J Joking with Fermat's Last Theorem Fermat's Last Theorem: no three positive integers a, b, and c can satisfy the equation an + bn = cn for any integer value of n greater than two. From the theorem, we know that a3 + b3 = c3 has no positive i…
Problem J. TriatripTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description The travel agency “Four Russians” is offering the new service for their clients. Unlike other agencies that only suggest one-way…
Problem J: 求个最大值 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 871  Solved: 663[Submit][Status][Web Board] Description 定义MaxValue类,用于求一系列非零整数的最大值.其中: 1. 数据成员elements用于存储所有输入的非零整数. 2. void append(int)用于向elements中添加一个新数据. 3. int getMax()用于求出elements中的…
Problem J. Journey with Pigshttp://codeforces.com/gym/241680/problem/J考察排序不等式算出来单位重量在每个村庄的收益,然后生序排列猪的重量也生序排列此时价值最大 #include<iostream> #include<cstdio> #include<queue> #include<algorithm> #include<cmath> #include<ctime>…
Problem J. Joke 题目连接: http://codeforces.com/gym/100714 Description The problem is to cut the largest possible number of circles with diameter y out of a stripe of length x and width y. Input The only line of input consists of two positive real number…