Skip to content

Commit a74a089

Browse files
committed
Merge branch 'main' of github.com:tkzzzzzz6/Algorithm_beginner_learning_notes
2 parents 0f8cbef + 02b3378 commit a74a089

15 files changed

Lines changed: 174 additions & 504 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<snippet>
2+
<content><![CDATA[
3+
#include <algorithm>
4+
#include <cmath>
5+
#include <cstdio>
6+
#include <cstdlib>
7+
#include <cstring>
8+
#include <iostream>
9+
#include <string>
10+
#include <vector>
11+
typedef long long ll;
12+
using namespace std;
13+
14+
int main() {
15+
int t;
16+
cin >> t;
17+
{1}
18+
19+
return 0;
20+
}
21+
22+
]]></content>
23+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
24+
<tabTrigger>ac</tabTrigger>
25+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
26+
<scope>source.c++</scope>
27+
</snippet>
Binary file not shown.

hydro_oj/NTU_2025_Freshman_Algo_Comp_OuterField/F. 有效电平/2.cpp

Whitespace-only changes.
Binary file not shown.
16.7 KB
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <algorithm>
2+
#include <iomanip>
3+
#include <cmath>
4+
#include <cstdio>
5+
#include <cstdlib>
6+
#include <cstring>
7+
#include <iostream>
8+
#include <string>
9+
#include <vector>
10+
#include <numbers>
11+
typedef long long ll;
12+
using namespace std;
13+
14+
const double PI = acos(-1.0);
15+
16+
int main() {
17+
ios::sync_with_stdio(false),cin.tie(0);
18+
cout << fixed << setprecision(10);
19+
int t;
20+
cin >> t;
21+
while(t--){
22+
int r,a;
23+
cin >> r >> a;
24+
cout << cos(a*PI/180.0)*r << ' ' << r*sin(a*PI/180.0) <<'\n';
25+
}
26+
27+
28+
return 0;
29+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[
2+
{
3+
"test": ""
4+
}
5+
]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <algorithm>
2+
#include <cmath>
3+
#include <cstdio>
4+
#include <cstdlib>
5+
#include <cstring>
6+
#include <iostream>
7+
#include <string>
8+
#include <vector>
9+
typedef long long ll;
10+
using namespace std;
11+
12+
vector<int>a;
13+
14+
int main() {
15+
ios::sync_with_stdio(false),cin.tie(0);
16+
int n,m;
17+
cin >> n >> m;
18+
a.resize(n);
19+
for(int i = 0;i<n;++i)cin >> a[i];
20+
21+
while(m--){
22+
int i;
23+
cin >> i;
24+
cout << a[i-1];
25+
if(m>0)cout << ' ';
26+
}
27+
cout << '\n';
28+
29+
return 0;
30+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <algorithm>
2+
#include <cmath>
3+
#include <cstdio>
4+
#include <cstdlib>
5+
#include <cstring>
6+
#include <iostream>
7+
#include <string>
8+
#include <vector>
9+
typedef long long ll;
10+
using namespace std;
11+
12+
string s;
13+
14+
int main() {
15+
ios::sync_with_stdio(false),cin.tie(0);
16+
int t;
17+
cin >> t;
18+
int cnt_0 = 0;
19+
for(int i = 0;i<t;++i){
20+
int x;
21+
cin >> x;
22+
if(x == 0)cnt_0++;
23+
}
24+
25+
if(cnt_0 == t){
26+
for(int i = 0;i<cnt_0;++i){
27+
s+='0';
28+
if(i<cnt_0-1)s+=' ';
29+
}
30+
s+='\n';
31+
cout << s;
32+
return 0;
33+
}
34+
for(int i = 0;i<cnt_0;++i)s+="0 ";
35+
for(int i = 1;i<(t-cnt_0);++i)s+="1 ";
36+
s+="1\n";
37+
38+
cout << s;
39+
40+
return 0;
41+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <iostream>
2+
3+
// 只包含必要的头文件
4+
5+
int main() {
6+
// 优化输入输出
7+
std::ios_base::sync_with_stdio(false);
8+
std::cin.tie(nullptr);
9+
10+
int t;
11+
std::cin >> t;
12+
13+
int cnt_0 = 0;
14+
// 使用一个临时变量 n 来保存原始的 t 值
15+
int n = t;
16+
while (t--) {
17+
int x;
18+
std::cin >> x;
19+
if (x == 0) {
20+
cnt_0++;
21+
}
22+
}
23+
24+
// 使用一个循环完成所有输出
25+
for (int i = 0; i < n; ++i) {
26+
// 在输出每个数字之前,先判断是不是第一个数
27+
// 如果不是第一个数,就先输出一个空格
28+
if (i > 0) {
29+
std::cout << ' ';
30+
}
31+
32+
// 根据当前是第几个数来决定输出 0 还是 1
33+
if (i < cnt_0) {
34+
std::cout << 0;
35+
} else {
36+
std::cout << 1;
37+
}
38+
}
39+
std::cout << '\n'; // 最后输出一个换行符
40+
41+
return 0;
42+
}

0 commit comments

Comments
 (0)