当前位置:网站首页>暑期总结(二)
暑期总结(二)
2022-07-29 06:40:00 【旦·】
这一周基本没太刷题,每天A的题也不多,但这一周整理了一下知识点,写了点笔记,因为每次看题解发现自己没有掌握的知识点太多了,总会卡住,所以这周就首先以知识点为主。不过我发现,题目看完题解,整个代码完整弄明白之后,再自己写,这个时候一次性A的可能非常非常大,最新几道题1A的概率较高。这周我想写两个思考比较久的题目:
1、P1808 单词分类
感觉很有技巧的一个题,先试用sort函数将输入的字符串排序,然后把排序后的字符串放入set集合中(借用set集合的去重),最后set中元素的个数就是答案。
#include<bits/stdc++.h>
using namespace std;
set<string> words;
int main(){
int t;
string temp;
cin>>t;
while(t--){
cin>>temp;
sort(temp.begin(),temp.end());
words.insert(temp); }
cout<<words.size()<<endl;
return 0;
}
2、P1029 最大公约数和最小公倍数问题
参考了题解的代码思路,可以看到不管哪一个P,Q它们都满足P × Q = x 0 × y 0 ,那么我们可以先用一个q表示y 0除以x 0的值(如果不能整除,输出0),然后从2开始看q能整除哪些数,用一个ans记录下来,最后答案为ans的2次方,这里模仿大佬的方法,左移一位代表2的次方。
#include<iostream>
using namespace std;
int x, y;
int main() {
cin >> x >> y;
if ((y%x) != 0) {
cout << 0 << endl;}
else {
int q
q= y / x;
int begin = 2;
int ans = 0;
while (q > 1) {
if ((q%begin) == 0) {
ans++;
while ((q%begin) == 0) {
q /= begin;}
}
begin++;
}
cout << (1 << ans) << endl;
}
return 0;
}
下一周以做题为主,加油!
边栏推荐
- npm install 时,卡住不动,五种解决方法
- 【charles日常问题】开启charles,使用不了钉钉
- Vscode remote debugging PHP solution through remotessh and Xdebug
- 我的创业邻居们
- Homebrew brew update 长时间没反应(或卡在 Updating Homebrew...)
- Simulation volume leetcode [normal] 081. Search rotation sort array II
- Operator3-设计一个operator
- 使用VsCode配置MySQL实现连接、查询、等功能
- Flink实时仓库-DWD层(kafka-关联mysql的lookup join)模板代码
- [C language brush leetcode] 67. binary sum (E)
猜你喜欢

Image noise and matrix inversion

Junda technology | applicable to "riyueyuan" brand ups wechat cloud monitoring card

数组的子集能否累加出K

Implementation of book borrowing management system based on C language

Flink实时仓库-DWD层(流量域)模板代码

基于C语言设计的学生成绩排名系统

Win11vmware turns on the virtual machine and restarts on the blue screen and the solution that cannot be started

Excel文件读写(创建与解析)

Student achievement ranking system based on C language design

城市花样精~侬好!DESIGN#可视化电台即将开播
随机推荐
接口测试实战项目03:执行测试用例
Google fragmented notes JWT (Draft)
Unity exploration plot access design analysis & process + code specific implementation
tp6 使用 ProtoBuf
Is online legend software testing training really so black hearted? Are they all scams?
Unity sends a post request to the golang server for parsing and returning
[C language brush leetcode] 2332. The latest time to get on the bus (m)
Vite3.0都发布了,你还能卷得动吗(新特性一览)
城市花样精~侬好!DESIGN#可视化电台即将开播
After three years of outsourcing, the salary of automatic testing after job hopping is twice that of the original. The secret is
buck电路boot电容短路和断路实测波形
微服务远程调用
Excel file reading and writing (creation and parsing)
Simulation volume leetcode [normal] 081. Search rotation sort array II
[C language brush leetcode] 1054. Bar code with equal distance (m)
gin 模版
Win11vmware turns on the virtual machine and restarts on the blue screen and the solution that cannot be started
做开发4年13K,想转行自动化测试,薪资还能涨吗···
Flink实时仓库-DWD层(kafka-关联mysql的lookup join)模板代码
Fillder use