当前位置:网站首页>暑期总结(二)
暑期总结(二)
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;
}
下一周以做题为主,加油!
边栏推荐
- [Charles' daily problems] when you open Charles, you can't use nails
- WPF 界面布局必知基础
- 2022-07-28:以下go语言代码输出什么?A:AA;B:AB;C:BA;D:BB。 package main import ( “fmt“ ) func main() { f
- WPF嵌套布局案例
- Flink real-time warehouse DWD layer (transaction domain - additional purchase dimension degradation processing) template code
- [C language brush leetcode] 1054. Bar code with equal distance (m)
- 图像加噪声与矩阵求逆
- 要不要满足客户所有的需求
- LeetCode 879. 盈利计划
- 接口测试实战项目03:执行测试用例
猜你喜欢

约瑟夫环问题

基于C语言实现图书借阅管理系统

怎么会不喜欢呢,CICD中轻松发送邮件

WPF嵌套布局案例

后缀自动机(SAM)讲解 + Luogu p3804【模板】后缀自动机 (SAM)

MVFuseNet:Improving End-to-End Object Detection and Motion Forecasting through Multi-View Fusion of

外包干了3年,跳槽后转自动化测试工资是原来的2倍,秘诀原来是......

微服务远程调用

Vmware16 create virtual machine: cannot create a new virtual machine, do not have permission to perform this operation

使用VsCode配置MySQL实现连接、查询、等功能
随机推荐
Summary of OCR optical character recognition methods
MySQL advanced (Advanced) SQL statement (I)
Vmware16 create virtual machine: cannot create a new virtual machine, do not have permission to perform this operation
后缀自动机(SAM)讲解 + Luogu p3804【模板】后缀自动机 (SAM)
VMware16安装虚拟机遇到的问题
谷歌零碎笔记之JWT(草稿)
Why does ETL often become ELT or even let?
gin 参数验证
[C language brush leetcode] 2332. The latest time to get on the bus (m)
ETL为什么经常变成ELT甚至LET?
SSH password free login - two virtual machines establish password free channel two-way trust
Thread synchronization - producers and consumers, tortoise and rabbit race, dual thread printing
微服务远程调用
路由中的生命周期钩子 - activated与deactivated
Cesium反射
个人博客系统(附源码)
Flink real-time warehouse DWD layer (transaction domain - additional purchase dimension degradation processing) template code
[C language brush leetcode] 67. binary sum (E)
我的创业邻居们
Vite3.0都发布了,你还能卷得动吗(新特性一览)