摘要:
使用sorted函数 n=int(input()) num=[int(x) for x in input().split()] mp={} for i in num: mp.setdefault(i,0) mp[i]=mp[i]+1 for i,j in sorted(mp.items()): pr 阅读全文
摘要:
错误提示很明显,就是编码方式不对。 原因: 在Windows下Python使用open()函数打开文件时会默认使用gbk解码。即使文件本身存储为UTF-8格式。 解决方案:指定参数encoding为utf-8 即: 将 with open('file_name', 'r') as f: 改为: wi 阅读全文
摘要:
知识点 按行取数据 代码: f=open("F:\\vsnode\\python\\water.txt","r+",encoding='utf-8') while True: line=f.readline() if not line :break line_list=list(line.split 阅读全文
摘要:
题意: 求有多少段连续的区间,他的区间和是k的倍数。 题解: 求取模后的前缀和,如果两点取模后的前缀和相同,则相减后、结果为零。也就是取模为零,也就是是k的倍数。 #include<bits/stdc++.h> #define int long long using namespace std; c 阅读全文