思维题
模拟,找规律
white Era
这个作者很懒,什么都没留下…
展开
-
Find 3-friendly Integers
思路:打印1-99的数没看出什么规律,但是到100以上的数就一定有连续的子序列mod3==0,根据直播听的鸽舍原理,以及同余原理可以知道,可以把每一位看成0,1或2,那么他们任意组合都满足 mod3 == 0所以,一百及一百以上的所有数都是3的friendly IntegerAC代码:#include <iostream>#include <stdio.h>using namespace std;int main(){ int t; sc.原创 2021-07-31 17:13:50 · 69 阅读 · 0 评论 -
C. Manhattan Subarrays
题目:https://codeforces.com/contest/1550/problem/CSuppose you have two points p=(xp,yp) and q=(xq,yq). Let’s denote the Manhattan distance between them as d(p,q)=|xp−xq|+|yp−yq|.Let’s say that three points p, q, r form a bad triple if d(p,r)=d(p,q)+d(q,r).原创 2021-07-25 14:36:30 · 133 阅读 · 0 评论 -
金币阵列问题
金币阵列问题,直接找规律,看看是先翻转行还是先变换列得到最少次数,废话少说上代码,,在写程序的过程中,打错一个bool值花了我半个小时调试。。。代码不要看着多,是因为我注重格式#include <iostream>using namespace std;const int SIZE = 101;int k, n, m, c, best; //分别表示例子个数,行数,列数,当前变换次数,最好变换次数bool found; //是否找到一种解int b0[SIZE][SIZE], b原创 2021-06-18 16:56:56 · 492 阅读 · 0 评论