有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整:   fun(A)     sum = 0     for i = 1 to A.length         for j = i+1 to A.length             sum = sum + Floor((A[i]+A[j])/(A[i]*A[j]))      return sum   给出数组A,由你来计算fun(A)的结果.例如:A = {1, 4, 1},fun(A) = [5/4] + [2/1]…
HackerRank   1305 Pairwise Sum and Divide   有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整:   fun(A)     sum = 0     for i = 1 to A.length         for j = i+1 to A.length             sum = sum + Floor((A[i]+A[j])/(A[i]*A[j]))      return sum   给出数组A,由你来计算fun(A…
1289 大鱼吃小鱼 有N条鱼每条鱼的位置及大小均不同,他们沿着X轴游动,有的向左,有的向右.游动的速度是一样的,两条鱼相遇大鱼会吃掉小鱼.从左到右给出每条鱼的大小和游动的方向(0表示向左,1表示向右).问足够长的时间之后,能剩下多少条鱼? Input 第1行:1个数N,表示鱼的数量(1 <= N <= 100000). 第2 - N + 1行:每行两个数A[i], B[i],中间用空格分隔,分别表示鱼的大小及游动的方向(1 <= A[i] <= 10^9,B[i] = 0 或 1…
1305 Pairwise Sum and Divide 题目来源: HackerRank 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整:   fun(A)     sum = 0     for i = 1 to A.length         for j = i+1 to A.length             sum = sum + Floor((A[i]+A[j])/(A[i…
Output 输出fun(A)的计算结果. Input示例 3 1 4 1 Output示例 4 first try: #include "bits/stdc++.h" using namespace std; #define LL long long #define INF 0x3f3f3f3f3f #define PI acos(-1) #define N 100010 #define MOD 10 LL arr[N]; LL fun(int n){ LL sum=; ;i<…
有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整:   fun(A)     sum = 0     for i = 1 to A.length         for j = i+1 to A.length             sum = sum + Floor((A[i]+A[j])/(A[i]*A[j]))      return sum   给出数组A,由你来计算fun(A)的结果.例如:A = {1, 4, 1},fun(A) = [5/4] + [2/1]…
1305 Pairwise Sum and Divide 题目来源: HackerRank 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整: fun(A)     sum = 0     for i = 1 to A.length         for j = i+1 to A.length             sum = sum + Floor((A[i]+A[j]…
  1305 Pairwise Sum and Divide 题目来源: HackerRank 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整:   fun(A)     sum = 0     for i = 1 to A.length         for j = i+1 to A.length             sum = sum + Floor((A[i]+…
题目链接:51nod 1305 Pairwise Sum and Divide 看完题我想都没想就直接暴力做了,AC后突然就反应过来了... Floor( (a+b)/(a*b) )=Floor( (1/b)+(1/a) ) 当a=1时:若b=1,则该式等于2,否则该式等于1 当a=b=2时:该式等于1 其余情况都等于0,所以只需要统计1和2的个数就行了. #include<cstdio> #include<algorithm> using namespace std; typed…
久しぶり! 发现的一道有意思的题,想了半天都没有找到规律,结果竟然是思路题..(在大佬题解的帮助下) 原题戳>>https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1305<< 有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整: fun(A)     sum = 0     for i = 1 to A.length         for j = i+1 to A.length  …
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90486252 1104 Sum of Number Segments (20 分)   Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.…
C. Plus and Square Root time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) an…
有趣的数学规律 椭圆 双曲线 抛物线都叫圆锥曲线 它们跟圆锥有着怎样的关系? 他们都是圆锥与平面在不同姿势下交配的产物. 参考 椭圆 抛物线 小结 e: 离线率 P: 任意一点 F: 焦点 准线: 一条直线 离心率 完美的圆轨离心率为0,椭圆的离线率在0到1之间,也就是说这个范围内,离心率越大,轨道就椭圆的越厉害(长短半轴差距越大.) 这里有很多天体的知识点 圆轨道:e=0\,\!, 椭圆轨道:{\displaystyle 0<e<1\,\!}, 抛物线轨道:e=1\,\!, 双曲线轨道:e&…
#1584 : Bounce 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 For Argo, it is very interesting watching a circle bouncing in a rectangle. As shown in the figure below, the rectangle is divided into N×M grids, and the circle fits exactly one grid. The bouncing…
Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3,…
链接: http://poj.org/problem?id=1844 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=29256#problem/D Sum Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 9795   Accepted: 6406 Description Consider the natural numbers from 1 to N. By a…
History repeat itself Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 434264-bit integer IO format: %I64d      Java class name: Main Prev Submit Status Statistics Discuss Next Type: None   None Graph Theory 2…
题目链接: https://vijos.org/p/1582 题目大意: 就是o(o<=50)个人在n*m(n,m<=2000)的格子上放L型的东西(有点像俄罗斯方块的L,可对称旋转),问第几个人覆盖全图或无解. 题目思路: [数学] n*m%8如果为0则(n*m/4-1)%o+1那个人胜利. 否则无解. (当时手画了大概8以内的几种样例,就感觉好像有规律可循,慢慢推但是感觉可能有错,于是偷偷瞄了一眼别人的题解,果然是规律题.但是我并不会证明.) // //by coolxxx // #inc…
题目连接:10706 - Number Sequence 题目大意:有一个有0 ~ 9组成的序列,1   1 2    1 2 3   1 2 3 4   1 2 3 4 5 ....就是第一位为1. 第二为为1 ,第三为为2, 然后10 的部分注意下, 为1  和0 两个, 100 就是1 , 0和0 三位,以此类推, 要求给出tmp, 输出序列中的tmp位为什么数字. 解题思路:数据很大,肯定不能模拟,找规律. 这两个是为推出来的用来打表的公式: 1.sum[i] = sum[i - 1]…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2154 很简单的找规律的数学题目: 思路:因为挑完N次后都要跳回A,所以相当于挑N-1次后必须留在B C区域,又由于B与C可以看作是对称的,所以每次算的时候可以假定全部先从B跳,最后结果乘以2就好.还可以用深度遍历的思想.每次尽量跳的路线远一点. 2 2 3 2 4 6 5 10 6 22 可以发现规律: if(i%2==0) a[i]=2*a[i-1]+2; else a[i]=2*a[i-1]-2;…
人民币的构造 Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu Submit Status Description 我们都知道人民币的面值是$1.2.5.10$,为什么是这个数值呢,我们分析了下发现,从$1-10$的每个数字都可以由每种面值选出至多一张通过加法和减法(找钱)来构成,(比如:$1+2=3,5-1=4,5+1=6,5+2=7,1+2+5=8,10-1=9$) 但是实际上,我们只需要$1.…
Visible Lattice Points 题目链接(点击) Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9031   Accepted: 5490 Description A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), other than the origin, is v…
题意: 一堆人用方块盖塔,有n个人每次只能加两块方块,有m个人每次只能加三块方块.要求每个人盖的塔的高度都不一样,保证所用方块数最少,求最高的塔的高度. 0<=n+m  0<=n,m<=1e6 思路: 根据容斥原理,n和m个人如果都按照等差为2或者3的序列盖塔的话那么重复的个数应该是塔高较小的那组除以6,然后....一开始顺着这个思路想把自己坑了... 其实可能的塔高是有规律的 2 3 4 6 8 9 10 12...每六个中有三个,所以干脆先打表了,那么知道n和m之后,至少需要n+m种…
题目链接 题意: 1-m中,四个数凑成一组,满足任意2个数的gcd=k,求一个最小的m使得凑成n组解.并输出 分析: 直接粘一下两个很有意思的分析.. 分析1: 那我们就弄成每组数字都互质,然后全体乘以k不就行了么…… 然后看了看样例…… 这个该怎么说……我是觉得额这道题的output暴露了数据规律怎么破……我算是看出规律再证明的方式A的这道题 当时我看到22那个样例的时候……在想他干嘛要把22放这里……然后发现 2/4/6/10 14/16/18/22也是行的哇…… 化成乘以k之前的数据………
E. Sum of Remainders 题目连接: http://www.codeforces.com/contest/616/problem/E Description The only line contains two integers n, m (1 ≤ n, m ≤ 1013) - the parameters of the sum. input The only line contains two integers n, m (1 ≤ n, m ≤ 1013) - the para…
C. Really Big Numbers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2160 中文题目,很简单,找规律就好. 自己画树状图找规律,开始想复杂了,找的规律:Fn=2*F(n-1)-(F(n-2)-F(n-4)),结果也是对的,但是弄复杂了,简单的规律: F1=1; F2=2; Fn=F(n-1)+f(n-2) (n>2) #include<stdio.h> int main() { int t,n,arr[22]; arr[1]=1; arr[2]=2; for(in…
The sum problem Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 31453    Accepted Submission(s): 9414 Problem Description Given a sequence 1,2,3,......N, your job is to calculate all the possib…
 1609: 求和 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 209  Solved: 67 SubmitStatusWeb Board Description 若S=15+195+1995+19995+···+199···95(n-1个9),则和数S的 末四位数字的和是多少(如果不够四位求各个位上的和)? Input 多实例测试,每组输入一个正整数n,n不大于1000000. Output 输出S的末四位数字之和 Sample Inpu…
f[1] = 'b', f[2] = 'a', f[i] = f[i - 1] + f[i - 2] 斐波那契数列的字符串,给你n和m,前m位中,最长的前缀等于后缀的长度是多少.1≤n≤1000, 1≤m≤length(f[n]) 规律题,虽然我不知道为什么. import java.io.*; import java.util.*; import java.math.*; public class Main{ //Scanner cin = Scanner(System.in); static…