当前位置:网站首页>Summer summary (II)
Summer summary (II)
2022-07-29 07:18:00 【Dan·】
This week, I didn't brush the questions too much , Every day A There are not many questions , But this week, I sorted out some knowledge points , Wrote some notes , Because every time I look at the problem solution, I find that I don't have too many knowledge points , It's always stuck , So this week will focus on knowledge points first . But I found out , After reading the title, the solution , After the whole code is completely understood , Write it yourself , This time one-time A The possibility is very, very large , The latest questions 1A There's a high probability that . This week I want to write two topics that I have been thinking about for a long time :
1、P1808 Word classification
A question that feels very skilled , Try it first sort Function sorts the input string , Then put the sorted string into set Collection ( To borrow set Set off the weight ), Last set The number of elements in is the answer .
#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 The problem of maximum common divisor and minimum common multiple
Refer to the code idea of the problem solution , You can see that no matter which one P,Q They are all satisfied P × Q = x 0 × y 0 , Then we can use one q Express y 0 Divide x 0 Value ( If it's not divisible , Output 0), And then from 2 Start looking at q What number can I divide by , Use one ans recorded , The final answer is ans Of 2 Power , Here imitate the way of the boss , Shift one delegate left 2 To the power of .
#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;
}
The next week will focus on questions , come on. !
边栏推荐
猜你喜欢

用户列表 圆形头像并跟随小板块

Record - step on the pit - real-time data warehouse development - doris/pg/flink

It's enough for MySQL to have this article (disgusting and crazy typing 37k words, just for Bo Jun's praise!!!)

2022-07-28: what is the output of the following go language code? A:AA; B:AB; C:BA; D:BB。 package main import ( “fmt“ ) func main() { f

Leetcode 879. profit plan

Operator3 - design an operator

Operator3-设计一个operator

Thoroughly understand kubernetes scheduling framework and plug-ins

Docker最新超详细教程——Docker创建运行MySQL并挂载

MutationObserver文档学习
随机推荐
作业7.28 文件IO与标准IO
Win11 system error: code execution cannot continue because ierutil.dll cannot be found. Reinstalling the program may fix this problem
Unity发送Post请求给GoLang服务端解析并返回
Gin service exit
计算程序运行时间 demo
Record - step on the pit - real-time data warehouse development - doris/pg/flink
MySQL 使用客户端以及SELECT 方式查看 BLOB 类型字段内容总结
MVFuseNet:Improving End-to-End Object Detection and Motion Forecasting through Multi-View Fusion of
外包干了3年,跳槽后转自动化测试工资是原来的2倍,秘诀原来是......
js中break与continue和return关键字
Gin routing, parameters, output
gin 服务退出
H3C_ Using setting default static routing priority to realize the active and standby function of export dual lines
如何使用gs_expansion扩展节点
Student achievement ranking system based on C language design
我的个人网站不让接入微信登录,于是我做了这个
2022-07-28:以下go语言代码输出什么?A:AA;B:AB;C:BA;D:BB。 package main import ( “fmt“ ) func main() { f
微服务远程调用
Vite3.0都发布了,你还能卷得动吗(新特性一览)
WPF simple login page completion case