// Problem: 密码锁
// Contest: AcWing
// URL: https://www.acwing.com/problem/content/1353/
// Memory Limit: 64 MB
// Time Limit: 1000 ms
// 2022-04-17 23:03:33
//
// Powered by CP Editor (https://cpeditor.org)#include<bits/stdc++.h>
using namespace std;#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,l,r) for(int i=(l);i>=(r);i--)
#define ll long long
#define mset(s,t) memset(s,t,sizeof(t))
#define mcpy(s,t) memcpy(s,t,sizeof(t))
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define mp make_pairtypedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> Vll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;                        const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const double pi  = acos(-1.0);
inline ll ksc(ll x,ll y,ll mod)
{ll ans = 0;while (y) {if (y & 1)ans = (ans + x) %mod;y >>= 1;x = (x + x) %mod;}return ans;
}
inline ll qmi (ll a, ll b) {ll ans = 1;while (b) {if (b & 1) ans = ans * a;a = a * a;b >>= 1;}return ans;
}
inline int read () {int x = 0, f = 0;char ch = getchar();while (!isdigit(ch)) f |= (ch=='-'),ch= getchar();while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();return f?-x:x;
}
template<typename T> void print(T x) {if (x < 0) putchar('-'), x = -x;if (x >= 10) print(x/10);putchar(x % 10 + '0');
}
inline ll sub (ll a, ll b) {return ((a - b ) %mod + mod) %mod;
}
inline ll add (ll a, ll b) {return (a + b) %mod;
}
// inline ll inv (ll a) {// return qmi(a, mod - 2);
// }
int x[3], y[3];
int n;
bool cmp (int a, int b, int c, int xx[]) {if (!(abs(xx[0] - a) <= 2 || abs(xx[0] - a) >= n - 2))return 0;if (!(abs(xx[1] - b) <= 2 || abs(xx[1] - b) >= n - 2))return 0;if (!(abs(xx[2] - c) <= 2 || abs(xx[2] - c) >= n - 2))return 0;return 1;
}
void solve() {
//  int n;cin >> n;if (n % 2) {for (int i =1 ; i<= n; i ++) {for (int j = i + 1;j <= n; j ++)if (j - i <= n / 2)cout << 1 <<" ";else cout << -1 << ' ';}puts("");}else {for (int i =1; i <= n; i ++) {for (int j = i + 1; j<= n; j ++) {if (j - i < n / 2) cout << 1 << " ";else if (j - i == n /2)cout << 0 << ' ';else cout << "-1 ";}}puts("");}}
int main () {// ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);int t;t =1;cin >> t;while (t --) solve();return 0;
}

对于n为奇数,我们可以令一半赢一般输,因为每个只比一场,如果最终要相等,那必须每个都要赢一场,对于当前的i 对于n为偶数,由于n * (n - 1) * 3 / 2 mod n !=0,所以需要让它减去t,使得能够被n整除 (n * (n - 1) * 3 / 2 - n / 2) % n == 0总共要减去n / 2次,这可以通过每次j - i == n / 2的位置实现 需要找到总分数的这个性质,以及对于偶数需要找到关键问题所在,那就是不能被n整除C. Minimum Ties

1487C - Minimum Ties相关推荐

  1. Educational Codeforces Round 104 (Rated for Div. 2)A~E解题报告

    Educational Codeforces Round 104 (Rated for Div. 2) A. Arena \quad原题链接 http://codeforces.com/contest ...

  2. Educational Codeforces Round 104 (Rated for Div. 2) A,B,C,D,E

    Educational Codeforces Round 104 (Rated for Div. 2) A,B,C,D,E A - Arena 题意 nnn 个英雄,他们的等级分别是 a1,a2,-, ...

  3. Educational Codeforces Round 104 (Rated for Div. 2)

    A. Arena 题目传送门: A. Arena 题目大意: 有n个人,每个人都有战斗力,当两个人打起来时,战斗力高的人赢并且战斗力加1,当战斗力达到100500时,则成为英雄.问能有多少人能成为英雄 ...

  4. Error:This Gradle plugin requires Studio 3.0 minimum

    导入一个demo提示Error:This Gradle plugin requires Studio 3.0 minimum 在gradle.properties中导入 android.injecte ...

  5. Error:The SDK Build Tools revision (23.0.3) is too low for project ':app'. Minimum required is 25.0.

    导入github上项目的时候出现 Error:The SDK Build Tools revision (23.0.3) is too low for project ':app'. Minimum ...

  6. [leetcode] Minimum Path Sum

    Minimum Path Sum Given a m x n grid filled with non-negative numbers, find a path from top left to b ...

  7. 【C++】C++11 STL算法(六):最小/最大操作(Minimum/maximum operations)、比较运算(Comparison operations)

    目录 最小/最大操作(Minimum/maximum operations) 一.max 1.原型: 2.说明: 3.官方demo 二.max_element 1.原型: 2.说明: 3.官方demo ...

  8. LeetCode 76. Minimum Window Substring / 567. Permutation in String

    76. Minimum Window Substring 典型Sliding Window的问题,维护一个区间,当区间满足要求则进行比较选择较小的字串,重新修改start位置. 思路虽然不难,但是如何 ...

  9. pandas使用max函数和min函数计算dataframe日期(时间)数据列中最大日期和最小日期对应的数据行(maximum and minimum date or time row)

    pandas使用max函数和min函数计算dataframe日期(时间)数据列中最大日期和最小日期对应的数据行(maximum and minimum date or time row in data ...

  10. pandas计算滑动窗口中的最小值实战(Rolling Minimum in a Pandas Column):计算单数据列滑动窗口中的最小值、计算多数据列滑动窗口中的最小值

    pandas计算滑动窗口中的最小值实战(Rolling Minimum in a Pandas Column):计算单数据列滑动窗口中的最小值.计算多数据列滑动窗口中的最小值 目录

最新文章

  1. 汕头金山中学2021高考成绩查询,2019汕头市金山中学录取分数线及2019高考成绩喜报...
  2. 云计算之路-阿里云上-幸福总是很突然:“黑色1秒”问题解决啦
  3. C++接口定义及实现举例
  4. python pyppeteer自定义chromium目录
  5. 机器学习Sklearn实战——手写线性回归
  6. java之hiberante之集合映射之list映射
  7. antd request 通过jsessionid传参数_Umi-request源码阅读
  8. 比IETEST更好用的浏览器兼容性测试软件[绿色]
  9. 单例模式在JDK应用的源码分析
  10. 开放外链后,阿里旗下多个App已接入微信支付:更方便了
  11. Halcon 基本算子释义
  12. 转载:Oracle导入导出命令的使用
  13. squid服务的应用 转
  14. HFSS----微带天线设计实例之模型分析优化
  15. VSLAM算法(二):PnP求解 3D-2D 相机位姿及 BA优化算法
  16. 向日葵设置开机自启动
  17. java导出用什么_Java导出Excel
  18. 在微信小游戏中开发一个贪食蛇
  19. arduino uno r3单片机封装图_单片机控制的OLED简易电子表原型
  20. 1.2.1 linux用户权限

热门文章

  1. 关于开通博客的一些感想
  2. 【寻找最佳小程序】02期:腾讯旅游首款小工具“旅行小账本”——创意及研发过程大起底...
  3. gyb优化事项(2)
  4. 【自动化测试selenium】
  5. CAP定理以及BASE定理详解
  6. [散文]茶想(作者:王莹莹)
  7. unittest框架中使用parameterized模块参数化
  8. Flink整合kafka并基于事件源生成时间戳以及水印
  9. 目标检测算法——YOLOv5/YOLOv7改进之结合CBAM
  10. C语言输入Aa1Bb2Cc3,C语言shuzu_test.doc