首页 > 数独数组
头像 Estrella_pi
发表于 2025-02-17 22:50:53
刚学语法不到一个月的新手,第一次在题解上发代码。 #include <algorithm> using namespace std; int cnt[10]; // 优化版, arr都不用开。 int main(){ int n, a; cin >> n; for( 展开全文
头像 牛客505100029号
发表于 2025-03-18 14:08:31
//解题思路:容易知道n为9的整数倍时,设倍数为x,则必须满足1~9每个数字的个数都是x个 // 若n=9*x+y,即多出y个多余的位置,则这多余的y个数不能重复 // 因为可随意调整顺序,保证前面x组1~9的前y个数和最后多出来的y个数顺序一致即可满足要求 //代码 展开全文
头像 叫啥名
发表于 2025-04-16 09:00:12
// #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432 #include <algorithm> #include <array> #include <iostream> using 展开全文
头像 番禺小韭菜
发表于 2025-03-05 17:50:14
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> nums(9); 展开全文
头像 牛客856751393号
发表于 2025-03-11 17:33:46
from collections import defaultdict while True: try: n = int(input()) num = list(map(int, input().split())) d = defaultdi 展开全文
头像 super_newcoder
发表于 2025-06-01 16:57:29
# 解题思路:容易知道n为9的整数倍时,设倍数为x,则必须满足1~9每个数字的个数都是x个 # 若n=9*x+y,即多出y个多余的位置,则这多余的y个数不能重复 # 因为可随意调整顺序,保证前面x组1~9的前y个数和最后多出来的y个数顺序一致即可满足要求 # //代码思路:设数组num[9],每个下 展开全文
头像 Leo米多
发表于 2025-05-20 11:56:25
def solve(nums): counts = [0]*9 for i in nums: if i >9 or i < 1: return False if i == 1: counts[ 展开全文
头像 扎男_
发表于 2025-04-17 16:28:16
//活动地址: 牛客春招刷题训练营 - 编程打卡活动 #include <algorithm> #include<iostream> using namespace std; int cnt[10];// 开一个数组来存储 每个数字出现的次数 // 优化版, arr都不用开 展开全文
头像 Aurea
发表于 2025-06-15 11:45:50
import sys a = int(input()) b = list(map(int, input().split())) c = [] for i in range(1, 10): c.append(b.count(i)) if max(c) - min(c) <= 1: 展开全文
头像 XiaoXiauwu
发表于 2025-04-17 19:45:53
水题,直接开个桶统计一下,然后分类讨论即可。要求每个数至少出现一次,且max出现次数-min出现次数 <= 1即可。具体构造方案类似于 789 123456789 1234...如果出现次数不是连续的,比如 2 2 2 3 3 2 3 2 2而非 3 3 2 2 2 2 2 2 3, 也可以构 展开全文

等你来战

查看全部