3 整除。3 整除,输出 −1。0 或 1(当且仅当 3∤i 时为 1),故 Smod3=(n−⌊n/3⌋)mod3,记为 r。1 与 2,减少量模 3 为 1。3 与 4(此时 n≥4),共减少 2。需要把 1 到 n 这 n 个互不相同的工号排成一个长度为 n 的排列 a1,a2,…,an,使得加权和 ∑i=1ni⋅ai 能被 3 整除。
请构造任意一个满足条件的排列。若无解,输出 −1。
测试组数 t 满足 1≤t≤104。每组的 n 满足 1≤n≤105,且单个测试文件中所有 n 之和不超过 105。
Scan the QR code below with WeChat to sign in
First-time scan will create your account automatically
请使用微信扫描下方二维码完成注册