C. Celex Update


题目大意:给出两点的坐标,找出不同的路径的总数(路径数字总和不同)

思路:根据观察向下走比向右走的增加幅度加1,所以在第i步 向下 对sum的影响是 n-i+1
所以最小数字为1+2+。。。。+y;
最大数字最大就是n+n-1+n-2+。。。+n-y;
我的代码:

#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#define INF 0x3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define re register
#define lson rt<<1
#define rson rt<<1|1
#define lowbit(a) ((a)&-(a))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define fi first
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define se secondusing namespace std;
typedef long long  ll;
typedef unsigned long long  ull;
typedef pair<int,int > pii;
const ll mod=10001;
const ll N =2e5+10;
const double eps = 1e-4;
//const double pi=acos(-1);
ll gcd(int a,int b){return !b?a:gcd(b,a%b);}
int dx[4]={-1,0,1,0} , dy[4] = {0,1,0,-1};
int a[N];
void solve()
{int x1,x2,y1,y2;cin>>x1>>y1>>x2>>y2;if(x1==x2||y1==y2) cout<<"1\n";else{int x=abs(x1-x2);int y=abs(y1-y2);ll k=x+y;ll any=(k-y)*y;cout<<any+1<<"\n";}
}
int main()
{int T;cin>>T;while(T--){solve();}return 0;
}

其实公式 可以整合为 x*y+1;

#include<bits/stdc++.h>
using namespace std;
int main()
{int t;cin>>t;while(t--){long long int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;cout<<(x2-x1)*(y2-y1)+1<<endl;}
}

思维--找规律--Codeforces Round #645 (Div. 2) c题相关推荐

  1. 双指针--Codeforces Round #645 (Div. 2) d题

    D. The Best Vacation 题目大意: 算出连续x天最多的拥抱,一个月第i号就有i个拥抱 思路:双指针,扫描过去(每个月每个月的计算,最后超出的部分再一天一天算) 代码 : #inclu ...

  2. Codeforces Round #645 (Div. 2) D. The Best Vacation

    Codeforces Round #645 (Div. 2) D. The Best Vacation 题目链接 You've been in love with Coronavirus-chan f ...

  3. codeforces Round #645 (Div. 2)D题解

    Codeforces Round #645 (Div. 2)--D题解 作为一名菜鸡,理所当然得没有A出来,这道题数据放小就一水题了,可惜数据这块卡的死死的. 本题最重要的一点就是你要推出来一个结论: ...

  4. Codeforces Round 700 (Div. 2) B题 英雄杀怪兽

    Codeforces Round 700 (Div. 2) B题 链接: https://codeforces.com/contest/1480/problem/B 大致意思: n组数据,每组数据的第 ...

  5. Codeforces Round #774 (Div. 2)E题题解

    Codeforces Round #774 (Div. 2) E. Power Board 题目陈述 有一个n×m(1≤n,m≤106)n\times m(1\le n,m\le10^6)n×m(1≤ ...

  6. Codeforces Round #645 (Div. 2) D - The Best Vacation 题解(二分+思维)

    题目链接 题目大意 一年有n个月,每个月有d[i]天,让你找出连续x天,使其日期的总和最大,可以跨年 题目思路 这里要发现一个性质:即连续的x天一定满足最后一天在月份的结尾,结论是显然的. 然后用两个 ...

  7. Codeforces Round #645 (Div. 2) E - Are You Fired? 题解(思维)

    题目链接 题目大意 给你一个长为n的数组前(n+1)/2个数为a[i],后面的数为x,让你求出一个长度k使其所有连续为k的数组之和都大于0 题目思路 首先要找性质,如果k满足,那么显然k*2也满足那么 ...

  8. Codeforces Round #645 (Div. 2) / contest 1358

    目录 A Park Lighting B Maria Breaks the Self-isolation C Celex Update D The Best Vacation E Are You Fi ...

  9. Codeforces Round #645 (Div. 2)(D.The Best Vacation)

    题目链接:https://codeforces.com/contest/1358/problem/D 思路:双指针+前缀和 前缀和主要处理了两组数据:sum[]是某月到某月的天数,ans[] 代表某月 ...

最新文章

  1. 哈希加密:MD5()
  2. 6.分布式数据库HBase第2部分
  3. BZOJ3434 [Wc2014]时空穿梭
  4. 入门——使用TensorFlow.js进行AI图像分类
  5. hive-0.11.0安装方法具体解释
  6. 选择排序两层遍历的目的
  7. 2013搜狐移动互联战略
  8. 钩子(hook)编程
  9. java setmethod_java.util.zip.ZipEntry.setMethod(int method)方法示例
  10. 自然语言处理——基于预训练模型的方法——第3章 基础工具集与常用数据集
  11. 计算机磁盘空间分区管理,还在用Win10自带磁盘管理? 这款软件轻松管理分区!...
  12. volo拉丁语_你为什么学习拉丁语?
  13. Intel SGX背景、其他可信计算技术和TEE技术(翻译自Intel SGX Explained)
  14. 定义网络营销,到底和网店有什么区别
  15. CRM软件的未来发展趋势
  16. 使用 TX2 和 realsense D435i 相机运行 ORBSLAM3
  17. ACCV 结果出来了,大家来晒一晒吧~
  18. kafka Reassign Partitions Tool
  19. Bandwagon Host IP Change修改IP
  20. 示波器播放Bad apple坏苹果教程XY模式

热门文章

  1. arraylist从大到小排序_经典排序方法的python实现和复杂度分析
  2. 我们该如何学习机器学习中的数学
  3. 最多金的编程语言Top10:Python第3,R第10,你猜第1是谁?
  4. 这本 “写不完” 的黑科技笔记本,恐怕要颠覆整个行业!
  5. 有效处理 Java 异常三原则
  6. linux 连接两个异构网,如何在Linux(或异构)网络上共享计算机?
  7. sql两个列值以下划线拼接得到一个新的列_面试必备sql知识点——MySQL基础
  8. android主动显示流程,Activity加载显示基本流程
  9. spyder pyecharts不显示_我的显示器需要定时校色吗?
  10. java web编写计算器_javaWeb 使用 jsp 和 javaBean 实现计算器功能