JDOJ 2782: 和之和】的更多相关文章

JDOJ 2782: 和之和 JDOJ传送门 Description 给出数n,求ans=(n+1)+(n+2)+...+(n+n) Input 一行,一个整数n Output 一行,一个整数ans%23333333333333333(2后面16个3) Sample Input 1 Sample Output 2 HINT 0<=n<=1012,实际上可能还会更小点 最优解声明及解题背景: (一道困扰了我半年的题)果然本蒟蒻还是太菜了/ 很多学弟和比我后学的都比我先切了这道题,但是我还迟迟没有…
Code: #include <iostream> #include <cstdio> #define setIO(s) freopen(s".in","r",stdin) #define ll long long #define mod 23333333333333333 using namespace std; int main(){ //setIO("input"); long long N,L,R,x,Ans =…
JDOJ 1140: 完数 题目传送门 Description 一个数如果恰好等于它的因子之和,这个数就称为"完数". 例如,6的因子为1.2.3,而6=1+2+3,因此6是"完数". 编程序找出N之内的所有完数,并按下面格式输出其因子: Input N Output ? its factors are ? ? ? Sample Input 1000 Sample Output 6 its factors are 1 2 3 28 its factors are 1…
Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero. To make problem a bit easier, all A, B, C, D have same length of N where 0 ≤ N ≤ 500. All integers are in the r…
Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24. 这道题让我们求一棵二叉树的所有左子叶的和,那么看到这道题我们知道这肯定是考二叉树的遍历问题,那么最简洁的写法肯定是用递归,由于我们只需要累加左子叶…
Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. Example: nums = [1, 2, 3] target = 4 The possible combination ways are: (1, 1, 1, 1) (1, 1, 2) (1,…
Given an array of n integers nums and a target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + nums[j] + nums[k] < target. For example, given nums = [-2, 0, 1, 3], and target = 2. Retu…
Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers. Ensure that numbers within the set are sorted in ascending order. Example 1…
Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead. For example, given the array [2,3,1,2,4,3] and s = 7,the subarray [4,3] has the minimal…
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total sum of all root-to-leaf numbers. For example, 1 / \ 2 3…