The ? 1 ? 2 ? ... ? n = k problem Theproblem Given the following formula, one can set operators '+' or '-' instead of each '?', in order to obtain a given k ? 1 ? 2 ? ... ? n = k For example: to obtain k = 12 , the expression to be used will be: -…
UVa10025 ? 1 ? 2 ? ... ? n = k problem The problem Given the following formula, one can set operators '+' or '-' instead of each '?', in order to obtain a given k? 1 ? 2 ? ... ? n = k For example: to obtain k = 12 , the expression to be used will be:…
The ? 1 ? 2 ? ... ? n = k problem The problem Given the following formula, one can set operators '+' or '-' instead of each '?', in order to obtain a given k ? 1 ? 2 ? ... ? n = k For example: to obtain k = 12 , the expression to be used will be: -…
option=com_onlinejudge&Itemid=8&page=show_problem&problem=4342">题目链接:uva 1567 - A simple stone game 题目大意:给定K和N.表示一堆石子有N个.先手第一次能够取1~N-1个石子,取到最后一个石子的人胜利,单词每次操作时,取的石子数不能超过对手上一次取的石子数m的K倍. 问先手能否够必胜.能够输出最小的首次操作. 解题思路:这题想了一天,又是打表找规律.又是推公式的,楞是…
题意: 给出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;…
分析:因为数字之间只有加减变换,所以-k和k是一样的,都可以当成整数来考虑,只要找到最小的n满足sum=n*(n+1)/2>=k:且sum和k同奇同偶即可,做法是用二分查找,然后在就近查找 因为1,2,3,4,5,6……的sum变化是奇奇偶偶奇奇偶偶奇奇偶偶…… 程序: import java.math.BigInteger; import java.util.Scanner; public class Main { static long l,r,mid; public static long…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 会链表的插入操作的话.这个就不难了. 放置两个哨兵节点. 然后模拟插入一个节点的过程就好. 实时修改光标就好->即下一个插入的位置. [代码] #include <bits/stdc++.h> using namespace std; const int N = 1e5; const int fir = 0, last = N + 10; int nex[N + 100],len,be; char s[N + 100];…