其实同POJ 1061 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; long long gcd(long long a,long long b){ if(b==0) return a; return gcd(b,a%b); } void exgcd(long long a,long long b,long…
链接:传送门 思路:拓展欧几里德模板题,设大圣至少翻转 t 次,大圣起始位置为 x ,大圣目标位置为 y + n * s ( 大圣到达目标位置 y 可能需要多圈,所以用 s 来表示圈数 ),因为只能逆时针翻转所以可以得到一个方程 x + D * t = y + n * s ( 使用D与d区分 ),将方程转换一下可以得到 D * t + n * s = y - x,求出 t 的最小正整数解即可,拓欧模板. /*********************************************…
链接: https://leetcode.com/problems/maximal-rectangle/ [描述] Given a 2D binary matrix filled with '0's and '1's, find the largest rectangle containing all ones and return its area. [中文描述] 给一个二维数组, 算出里面最大的全1矩形面积,比如: [ ['1','1','1','0'], ['1','1','1','1']…