Skip to content

Commit 0a61d49

Browse files
committed
order topics by syllabus
1 parent fd6e601 commit 0a61d49

16 files changed

+61
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

02-Mathematics/2309.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <iostream>
2+
#include <cmath>
3+
using namespace std;
4+
5+
void solve(int number){
6+
int all = (int)(log((double)number) / log(2.0));
7+
int root = (int)pow(2.0,(double)all);
8+
int level = 0;
9+
// cout << root << endl;
10+
while (level < all) {
11+
if (root == number) {
12+
break;
13+
}
14+
15+
if (root > number) {
16+
root -= (int)pow(2.0, all - level - 1);
17+
level++;
18+
}
19+
20+
if (root < number) {
21+
root += (int)pow(2.0, all - level - 1);
22+
level++;
23+
}
24+
}
25+
26+
int min = number - (int)pow(2.0, all - level) + 1;
27+
int max = number + (int)pow(2.0, all - level) - 1;
28+
29+
cout << min << " " << max << endl;
30+
}
31+
32+
int main(){
33+
int n,a;
34+
cin >> n;
35+
while(n--){
36+
cin >> a;
37+
solve(a);
38+
}
39+
}
305 KB
Binary file not shown.

03-Data Structures/2418.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <iostream>
2+
#include <map>
3+
#include <string>
4+
#include <iomanip>
5+
using namespace std;
6+
int main(){
7+
map<string,int> m;
8+
string s;
9+
double all = 0.0;
10+
while(getline(cin,s)){
11+
all++;
12+
if(m.find(s) != m.end()){
13+
m[s]++;
14+
}else{
15+
m[s] = 1;
16+
}
17+
}
18+
for (std::map<string,int>::iterator it=m.begin(); it!=m.end(); ++it){
19+
cout << it-> first << " ";
20+
printf("%.4f\n",(it->second / all) * 100);
21+
}
22+
}

0 commit comments

Comments
 (0)