├── WHUT ├── 2021 │ ├── Week_04 │ │ ├── H.c │ │ ├── I.c │ │ ├── G.c │ │ └── E.c │ ├── Week_02 │ │ ├── A.c │ │ ├── B.c │ │ ├── C.c │ │ ├── K.c │ │ ├── H.c │ │ ├── E.c │ │ ├── O.c │ │ ├── F.c │ │ ├── D.c │ │ └── M.c │ ├── Week_01 │ │ ├── G.c │ │ ├── A.c │ │ ├── C.c │ │ ├── B.c │ │ ├── F.c │ │ ├── D.c │ │ ├── E.c │ │ └── H.c │ ├── TeamExercise_06 │ │ └── tet.cpp │ ├── CampusExercise_01 │ │ ├── A.cpp │ │ ├── D.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ ├── T.cpp │ │ ├── K.cpp │ │ ├── C.cpp │ │ ├── P.cpp │ │ ├── G.cpp │ │ ├── R.cpp │ │ ├── M.cpp │ │ ├── H.cpp │ │ ├── L.cpp │ │ ├── Q.cpp │ │ └── I.cpp │ ├── Week_03 │ │ ├── H.c │ │ ├── G.c │ │ ├── F.c │ │ ├── L.c │ │ ├── O.c │ │ ├── J.c │ │ ├── M.c │ │ └── I.c │ ├── TeamExercise_04 │ │ ├── A.py │ │ ├── H.py │ │ ├── C.py │ │ ├── A.cpp │ │ ├── H.cpp │ │ └── C.cpp │ ├── Week_08 │ │ ├── A.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ ├── B.cpp │ │ ├── G.cpp │ │ └── test.cpp │ ├── CampusExercise_02 │ │ ├── B.cpp │ │ ├── H.cpp │ │ ├── I.cpp │ │ ├── J.cpp │ │ └── M.cpp │ ├── Week_09 │ │ ├── C.cpp │ │ ├── D.cpp │ │ ├── !E.cpp │ │ ├── B.cpp │ │ └── A.cpp │ ├── Exercise_02-Div2 │ │ ├── L.cpp │ │ ├── G.cpp │ │ └── A.cpp │ ├── TeamExercise_08 │ │ ├── E.cpp │ │ └── C_useDP.cpp │ ├── TeamExercise_01 │ │ ├── D_TLE.cpp │ │ └── B.cpp │ └── Week_05 │ │ └── A.c ├── 2022 │ ├── Week01 │ │ ├── A.cpp │ │ ├── C.cpp │ │ ├── G.cpp │ │ ├── L.cpp │ │ ├── B.cpp │ │ ├── D.cpp │ │ ├── F.cpp │ │ ├── E.cpp │ │ ├── H.cpp │ │ └── J.cpp │ ├── Week02 │ │ ├── A.cpp │ │ ├── J.cpp │ │ ├── B.cpp │ │ ├── E.cpp │ │ ├── F.cpp │ │ ├── G.cpp │ │ ├── I.cpp │ │ └── D.cpp │ ├── Homework │ │ ├── C.cpp │ │ ├── R.cpp │ │ ├── U.cpp │ │ └── Y.cpp │ ├── Train02 │ │ ├── H.cpp │ │ └── A.cpp │ ├── Week04 │ │ ├── A.cpp │ │ ├── F.cpp │ │ ├── C.cpp │ │ └── L.cpp │ ├── Week03 │ │ ├── F.cpp │ │ ├── E.cpp │ │ ├── C.cpp │ │ ├── B.cpp │ │ └── J.cpp │ ├── Week06 │ │ └── F.cpp │ └── Mystery │ │ └── B.cpp └── 2023 │ ├── Summer03 │ └── G_test.py │ ├── GPLT05 │ ├── L1-1.cpp │ ├── L1-2.cpp │ └── L1-4.cpp │ ├── GPLT01 │ ├── L1-4.cpp │ ├── L1-3.cpp │ └── L1-5.cpp │ ├── GPLT03 │ ├── L1-1.cpp │ ├── L1-2.cpp │ ├── L1-3.cpp │ └── L1-4.cpp │ ├── GPLT04 │ ├── L1-1.cpp │ ├── L1-2.cpp │ ├── L1-4.cpp │ └── L1-7.cpp │ ├── GPLT02 │ ├── L1-3.cpp │ ├── L1-7.cpp │ ├── L1-4.cpp │ ├── L1-5.cpp │ └── L1-8.cpp │ └── Summer01 │ └── B.cpp ├── Hello World.py ├── Contest ├── Other │ ├── GPLT Campus Contest Exercise │ │ ├── L2-3.cpp │ │ ├── L1-1.cpp │ │ ├── L1-2.cpp │ │ ├── L1-7.py │ │ ├── L1-3.cpp │ │ └── L1-4.cpp │ ├── GPLT Campus Contest 2023 │ │ ├── 二维码.png │ │ ├── L1-1.cpp │ │ ├── L1-2.cpp │ │ └── L1-3.cpp │ ├── GPLT Campus Contest │ │ ├── GPLT QR Code.png │ │ ├── 7-1.cpp │ │ ├── 7-2.cpp │ │ └── 7-6.cpp │ ├── HRBUST 2021 │ │ ├── C.cpp │ │ ├── B.cpp │ │ ├── E.cpp │ │ ├── H.cpp │ │ └── A.cpp │ ├── CCNU CaiNiaoBei │ │ ├── A.cpp │ │ ├── J.cpp │ │ └── B.cpp │ ├── ChuanZhiBei 05 │ │ ├── A.cpp │ │ └── C.cpp │ ├── HUSRFC 2023 │ │ ├── D.cpp │ │ └── K.cpp │ ├── WHU 2023 │ │ ├── L.cpp │ │ └── E.cpp │ ├── Robocom Province Contest │ │ └── RC-u1.cpp │ └── Nowcoder Beginner Contest │ │ └── 43 │ │ └── D.cpp ├── Codeforces │ ├── Other │ │ ├── April Fools Day Contest 2023 │ │ │ ├── J.txt │ │ │ ├── A.cpp │ │ │ ├── D.cpp │ │ │ ├── E.cpp │ │ │ └── B.cpp │ │ ├── Educational #137 (Rated for Div. 2) │ │ │ ├── _A.cpp │ │ │ └── _B.cpp │ │ ├── Global Round #24 │ │ │ ├── _A.cpp │ │ │ └── _B.cpp │ │ ├── Nebius Welcome Round (Div. 1 + Div. 2) │ │ │ └── A.cpp │ │ ├── Code TON #3 (Div. 1 + Div. 2) │ │ │ └── _A.cpp │ │ ├── Educational #138 (Rated for Div. 2) │ │ │ └── A.cpp │ │ ├── Educational #152 (Rated for Div. 2) │ │ │ └── A.cpp │ │ ├── Global Round #23 │ │ │ ├── _C_better.cpp │ │ │ └── A.cpp │ │ └── Educational #149 (Rated for Div. 2) │ │ │ └── A.cpp │ └── Regular │ │ ├── #827 (Div. 4) │ │ └── A.cpp │ │ ├── #839 (Div. 3) │ │ └── A.cpp │ │ ├── #829 (Div. 2) │ │ ├── _B.cpp │ │ └── _D.cpp │ │ ├── #835 (Div. 4) │ │ ├── _B.cpp │ │ ├── _A.cpp │ │ └── _C.cpp │ │ ├── #836 (Div. 2) │ │ └── _A.cpp │ │ ├── #834 (Div. 3) │ │ └── A.cpp │ │ ├── #859 (Div. 4) │ │ └── A.cpp │ │ ├── #832 (Div. 2) │ │ ├── _C.cpp │ │ ├── _B.cpp │ │ └── _A.cpp │ │ ├── #830 (Div. 2) │ │ └── _B.cpp │ │ ├── #909 (Div. 3) │ │ └── A.cpp │ │ ├── #855 (Div. 3) │ │ └── D.cpp │ │ ├── #849 (Div. 4) │ │ ├── A.cpp │ │ └── C.cpp │ │ ├── #867 (Div. 3) │ │ ├── C.cpp │ │ └── B.cpp │ │ ├── #874 (Div. 3) │ │ └── A.cpp │ │ ├── #871 (Div. 4) │ │ └── A.cpp │ │ ├── #875 (Div. 2) │ │ └── A.cpp │ │ ├── #847 (Div. 3) │ │ └── _A.cpp │ │ ├── #844 (Div. 1 + Div. 2) │ │ └── A.cpp │ │ ├── #883 (Div. 3) │ │ └── A.cpp │ │ ├── #825 (Div. 2) │ │ └── _C1.cpp │ │ └── #831 (Div. 1 + Div. 2) │ │ └── _C.cpp ├── AtCoder │ ├── Beginner │ │ ├── 236 │ │ │ ├── A.cpp │ │ │ ├── B.cpp │ │ │ └── C.cpp │ │ ├── 237 │ │ │ ├── A.cpp │ │ │ ├── B.cpp │ │ │ └── D.cpp │ │ ├── 238 │ │ │ ├── A.cpp │ │ │ ├── _D.cpp │ │ │ └── B.cpp │ │ ├── 239 │ │ │ ├── B.py │ │ │ └── A.cpp │ │ ├── 241 │ │ │ └── A.cpp │ │ ├── 242 │ │ │ ├── A.cpp │ │ │ └── B.cpp │ │ ├── 245 │ │ │ ├── B.cpp │ │ │ └── A.cpp │ │ ├── 246 │ │ │ ├── B.cpp │ │ │ ├── A.cpp │ │ │ └── _D_PublicSolution.cpp │ │ ├── 247 │ │ │ ├── A.cpp │ │ │ └── C.cpp │ │ ├── 248 │ │ │ ├── B.cpp │ │ │ ├── A.cpp │ │ │ └── D_TLE.cpp │ │ ├── 250 │ │ │ ├── A.cpp │ │ │ └── _E_Kiri8128_hash.py │ │ ├── 251 │ │ │ └── A.cpp │ │ ├── 253 │ │ │ ├── A.cpp │ │ │ ├── D.cpp │ │ │ └── B.cpp │ │ ├── 254 │ │ │ └── A.cpp │ │ ├── 256 │ │ │ └── A.cpp │ │ ├── 261 │ │ │ ├── A.cpp │ │ │ └── C.cpp │ │ ├── 262 │ │ │ ├── A.cpp │ │ │ └── C.cpp │ │ ├── 263 │ │ │ └── _D.cpp │ │ ├── 265 │ │ │ └── A.cpp │ │ ├── 267 │ │ │ └── A.cpp │ │ ├── 268 │ │ │ ├── A.cpp │ │ │ ├── B.cpp │ │ │ └── C.cpp │ │ ├── 269 │ │ │ ├── A.cpp │ │ │ ├── B.cpp │ │ │ └── C.cpp │ │ ├── 270 │ │ │ ├── _D.cpp │ │ │ └── B.cpp │ │ ├── 271 │ │ │ ├── A.cpp │ │ │ └── B.cpp │ │ ├── 272 │ │ │ └── A.cpp │ │ ├── 274 │ │ │ ├── A.cpp │ │ │ ├── C.cpp │ │ │ └── B.cpp │ │ ├── 276 │ │ │ ├── A.cpp │ │ │ ├── C.cpp │ │ │ └── B.cpp │ │ ├── 279 │ │ │ ├── B.cpp │ │ │ ├── A.cpp │ │ │ └── D.py │ │ ├── 280 │ │ │ ├── B.cpp │ │ │ ├── C.cpp │ │ │ └── A.cpp │ │ ├── 281 │ │ │ └── A.cpp │ │ ├── 282 │ │ │ ├── A.cpp │ │ │ └── C.cpp │ │ ├── 283 │ │ │ ├── C.cpp │ │ │ └── A.cpp │ │ ├── 284 │ │ │ ├── A.cpp │ │ │ └── B.cpp │ │ ├── 292 │ │ │ └── A.cpp │ │ └── 293 │ │ │ └── A.cpp │ └── Regular │ │ └── 144 │ │ ├── A.cpp │ │ └── B_TLE.cpp └── NCSummer │ ├── Contest_01 │ ├── D.cpp │ └── _D.cpp │ └── Contest_06 │ └── _C.py ├── LuoGu ├── 5000~5999 │ ├── P5704.py │ ├── P5703.py │ ├── P5715.py │ ├── P5704.c │ ├── P5703.c │ ├── P5708.py │ ├── P5705.c │ ├── P5706.c │ ├── P5720.c │ ├── P5722.c │ ├── P5710.py │ ├── P5710.c │ ├── P5711.c │ ├── P5712.c │ ├── P5713.c │ ├── P5708.c │ ├── P5015.cpp │ ├── P5721.c │ ├── P5743.cpp │ ├── P5739.cpp │ ├── P5709.c │ ├── P5718.c │ ├── P5733.cpp │ ├── P5724.c │ ├── P5715.c │ ├── P5737.cpp │ ├── P5714.cpp │ ├── P5716.c │ ├── P5742.cpp │ ├── P5707.c │ ├── P5719.c │ ├── P5726.c │ ├── P5727.cpp │ ├── P5744.cpp │ ├── P5732.cpp │ ├── P5723.c │ ├── P5736.cpp │ ├── P5738.cpp │ ├── P5735.cpp │ ├── P5788.cpp │ └── P5725.c ├── 1000~1999 │ ├── P1001.py │ ├── P1001.c │ ├── P1421.c │ ├── P1035.c │ ├── P1720.c │ ├── P1075.c │ ├── P1425.c │ ├── P1914.cpp │ ├── P1085.c │ ├── P1424.c │ ├── P1423.cpp │ ├── P1427.cpp │ ├── P1046.c │ ├── P1307.c │ ├── P1059.cpp │ ├── P1217.cpp │ ├── P1028.cpp │ ├── P1012.cpp │ ├── P1909.cpp │ ├── P1428.cpp │ ├── P1980.c │ ├── P1422.c │ ├── P1420.c │ ├── P1164.cpp │ ├── P1116.cpp │ ├── P1319.cpp │ ├── P1088_2.cpp │ ├── P1200.cpp │ ├── P1554.cpp │ ├── P1089.c │ ├── P1152.cpp │ ├── P1102.cpp │ ├── P1614.cpp │ ├── P1090.cpp │ ├── P1216.cpp │ ├── P1161.cpp │ └── P1765.cpp ├── 3000~3999 │ ├── P3954.py │ ├── P3954.c │ └── P3817.cpp ├── 2000~2999 │ ├── B2002.cpp │ ├── B2025.cpp │ ├── P2181.cpp │ ├── B2005.cpp │ ├── B2029.cpp │ ├── P2415.cpp │ ├── P2669.c │ ├── P2249.cpp │ ├── B2124.cpp │ ├── P2241.cpp │ ├── P2676.cpp │ └── B2118.cpp └── 4000~4999 │ └── P4956.c ├── .gitignore ├── Hello World.c ├── README.md ├── Hello World.cpp ├── AcWing ├── 800~899 │ ├── 888.py │ ├── 891.cpp │ ├── 892.cpp │ ├── 872.cpp │ ├── 830.cpp │ ├── 866.cpp │ ├── 877.cpp │ ├── 896.cpp │ ├── 897.cpp │ ├── 875.cpp │ ├── 873.cpp │ └── 867.cpp ├── 100~199 │ └── 104.cpp ├── 700~799 │ ├── 790.cpp │ ├── 795.cpp │ └── 789.cpp └── 900~999 │ ├── 913.cpp │ └── 905.cpp └── Misc ├── Completebag_Optimized_2.cpp ├── 01bag_Optimized.cpp ├── Completebag.cpp ├── Multiplebag.cpp └── Completebag_Optimized.cpp /WHUT/2021/Week_04/H.c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /WHUT/2021/Week_04/I.c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Hello World.py: -------------------------------------------------------------------------------- 1 | print('Hello World!') -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest Exercise/L2-3.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5704.py: -------------------------------------------------------------------------------- 1 | a = input() 2 | print(a.upper()) 3 | -------------------------------------------------------------------------------- /Contest/Codeforces/Other/April Fools Day Contest 2023/J.txt: -------------------------------------------------------------------------------- 1 | please -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/239/B.py: -------------------------------------------------------------------------------- 1 | X = int(input()) 2 | print(X // 10) 3 | -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1001.py: -------------------------------------------------------------------------------- 1 | l = input().split() 2 | print(int(l[0]) + int(l[1])) 3 | -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5703.py: -------------------------------------------------------------------------------- 1 | a = input().split() 2 | print(int(a[0]) * int(a[1])) 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !*.* 3 | !*/ 4 | .vscode 5 | .cph 6 | *.exe 7 | tempCodeRunnerFile.* 8 | test.* 9 | temp.* -------------------------------------------------------------------------------- /LuoGu/3000~3999/P3954.py: -------------------------------------------------------------------------------- 1 | a = input().split() 2 | print(int(int(a[0]) * 0.2 + int(a[1]) * 0.3 + int(a[2]) * 0.5)) 3 | -------------------------------------------------------------------------------- /Hello World.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | printf("Hello World!\n"); 6 | return 0; 7 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_02/A.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | printf("Hello, World!"); 6 | return 0; 7 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Algorithm-Problems 2 | 3 | 写过的算法题的代码,绝大部分使用 C++,少部分使用 C 和 Python. 4 | 5 | 数据结构与算法模板可前往:[Snippet.md](./Snippet.md) 6 | -------------------------------------------------------------------------------- /WHUT/2021/Week_02/B.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int a; 6 | scanf("%d", &a); 7 | printf("%c", a); 8 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5715.py: -------------------------------------------------------------------------------- 1 | l = input().split() 2 | sl = [int(l[0]), int(l[1]), int(l[2])] 3 | sl.sort() 4 | print(f"{sl[0]} {sl[1]} {sl[2]}") 5 | -------------------------------------------------------------------------------- /WHUT/2021/Week_01/G.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a,b; 6 | while(scanf("%d%d",&a,&b)!=EOF) 7 | printf("%d\n\n",a+b); 8 | } -------------------------------------------------------------------------------- /Hello World.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "Hello World!" << endl; 8 | return 0; 9 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5704.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | char c; 6 | scanf("%c", &c); 7 | printf("%c", c - 32); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest 2023/二维码.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChrisKimZHT/Algorithm-Problems/master/Contest/Other/GPLT Campus Contest 2023/二维码.png -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1001.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int a, b; 6 | scanf("%d%d", &a, &b); 7 | printf("%d\n", a + b); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5703.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int a, b; 6 | scanf("%d%d", &a, &b); 7 | printf("%d\n", a * b); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /WHUT/2023/Summer03/G_test.py: -------------------------------------------------------------------------------- 1 | for i in range(1, 21): 2 | bin_str = bin(i)[2:] 3 | bin_str = '0' * (i - len(bin_str)) + bin_str 4 | print(i, bin_str) 5 | -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest/GPLT QR Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChrisKimZHT/Algorithm-Problems/master/Contest/Other/GPLT Campus Contest/GPLT QR Code.png -------------------------------------------------------------------------------- /LuoGu/2000~2999/B2002.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "Hello,World!" << endl; 8 | return 0; 9 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_01/A.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | int a, b; 6 | while (scanf("%d%d", &a, &b) != EOF) 7 | printf("%d\n", a + b); 8 | } -------------------------------------------------------------------------------- /LuoGu/2000~2999/B2025.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << " *\n ***\n*****\n ***\n *" << endl; 8 | return 0; 9 | } -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest/7-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "Always Challenge Miracle!" << endl; 8 | return 0; 9 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5708.py: -------------------------------------------------------------------------------- 1 | l = input().split() 2 | a, b, c = float(l[0]), float(l[1]), float(l[2]) 3 | p = (a + b + c) / 2 4 | print(format((p * (p - a) * (p - b) * (p - c)) ** 0.5, '.1f')) 5 | -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5705.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | char a, b, c, d; 6 | scanf("%c%c%c%*c%c", &a, &b, &c, &d); 7 | printf("%c.%c%c%c", d, c, b, a); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5706.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n; 6 | double t; 7 | scanf("%lf%d", &t, &n); 8 | printf("%.3lf\n%d", t / n, n * 2); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /WHUT/2021/TeamExercise_06/tet.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | char str[20]; 8 | scanf("%s", str); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest 2023/L1-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "May the force be with you." << endl; 8 | return 0; 9 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int A, B; 8 | cin >> A >> B; 9 | cout << A + B << endl; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1421.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int a, b, x, ans; 6 | scanf("%d%d", &a, &b); 7 | x = 10 * a + b; 8 | ans = x / 19; 9 | printf("%d", ans); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /AcWing/800~899/888.py: -------------------------------------------------------------------------------- 1 | a, b = input().split(' ') 2 | a = int(a) 3 | b = int(b) 4 | res = 1 5 | for i in range(a - b + 1, a + 1): 6 | res *= i 7 | for i in range(1, b + 1): 8 | res //= i 9 | print(res) 10 | -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5720.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int a, i; 6 | scanf("%d", &a); 7 | for (i = 1; a > 1; i++) 8 | { 9 | a /= 2; 10 | } 11 | printf("%d", i); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /WHUT/2022/Week01/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b; 8 | while (cin >> a >> b) 9 | cout << a + b << endl; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /LuoGu/3000~3999/P3954.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int A, B, C, score; 6 | scanf("%d%d%d", &A, &B, &C); 7 | score = .2 * A + .3 * B + .5 * C; 8 | printf("%d", score); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5722.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n, ans; 6 | scanf("%d", &n); 7 | for (int i = 1; i <= n; i++) 8 | { 9 | ans += i; 10 | } 11 | printf("%d", ans); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /WHUT/2022/Week01/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b; 8 | while (cin >> a >> b && (a || b)) 9 | cout << a + b << endl; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT05/L1-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "I'm gonna win! Today!" << endl; 8 | cout << "2022-04-23" << endl; 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/239/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int H; 8 | scanf("%d", &H); 9 | printf("%lf", sqrt(1.0 * H * (12800000 + H))); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest 2023/L1-2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int C, B; 8 | cin >> C >> B; 9 | cout << (C ^ B) << endl; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest Exercise/L1-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string S; 8 | cin >> S; 9 | cout << "Hello " << S << endl; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_01/C.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a, b; 6 | while(scanf("%d%d", &a, &b) != EOF) 7 | { 8 | if(a==0 && b == 0) 9 | break; 10 | printf("%d\n", a + b); 11 | } 12 | return 0; 13 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/254/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string N; 8 | cin >> N; 9 | cout << N[N.size() - 2] << N[N.size() - 1] << endl; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /WHUT/2022/Week01/G.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b; 8 | while (cin >> a >> b) 9 | cout << a + b << '\n' 10 | << endl; 11 | return 0; 12 | } -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest Exercise/L1-2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int A, B; 8 | cin >> A >> B; 9 | printf("%d/%.1lf=%d", A, 1.0 * A / B, B); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1035.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int k, i; 6 | double S = 0; 7 | scanf("%d", &k); 8 | for (i = 1; S <= k; i++) 9 | { 10 | S += 1.0 / i; 11 | } 12 | printf("%d", i - 1); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5710.py: -------------------------------------------------------------------------------- 1 | num = int(input()) 2 | feat1 = not(num & 1) 3 | feat2 = num > 4 and num <= 12 4 | print(f"{int(feat1 & feat2)} {int(feat1 | feat2)} {int((feat1 and (not(feat2))) or (not(feat1) and feat2))} {int(not(feat1) and not(feat2))}") 5 | -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/251/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string S; 8 | cin >> S; 9 | for (int i = 0; i < 6 / S.size(); i++) 10 | cout << S; 11 | return 0; 12 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/274/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int A, B; 8 | cin >> A >> B; 9 | cout << fixed << setprecision(3) << 1.0 * B / A << endl; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest Exercise/L1-7.py: -------------------------------------------------------------------------------- 1 | x = int(input()) 2 | 3 | num = 0 4 | 5 | for i in range(1, 10000000): 6 | num *= 10 7 | num += 1 8 | if num % x == 0: 9 | print(f"{int(num // x)} {i}") 10 | break 11 | -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int a1, a2, n; 8 | cin >> a1 >> a2 >> n; 9 | int d = a2 - a1; 10 | cout << a1 + (n - 1) * d << endl; 11 | return 0; 12 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_01/B.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int count, a, b, i; 6 | scanf("%d", &count); 7 | for(i = 0; i < count; i++) 8 | { 9 | scanf("%d%d", &a, &b); 10 | printf("%d\n", a + b); 11 | } 12 | return 0; 13 | } -------------------------------------------------------------------------------- /WHUT/2022/Week02/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long n; 8 | while (cin >> n) 9 | cout << (1 + n) * n / 2 << '\n' 10 | << endl; 11 | return 0; 12 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/236/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | string S; 8 | int a, b; 9 | cin >> S >> a >> b; 10 | swap(S[a - 1], S[b - 1]); 11 | cout << S << endl; 12 | return 0; 13 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5710.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int x, a, b; 6 | scanf("%d", &x); 7 | a = x % 2 == 0; 8 | b = x > 4 && x <= 12; 9 | printf("%d %d %d %d", a & b, a | b, a && !b || b && !a, !a && !b); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/262/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int Y; 8 | cin >> Y; 9 | int ans = Y + 2 - Y % 4; 10 | cout << (ans >= Y ? ans : ans + 4) << endl; 11 | return 0; 12 | } -------------------------------------------------------------------------------- /LuoGu/2000~2999/P2181.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | unsigned long long n,ans; 4 | int main() 5 | { 6 | scanf("%lld",&n); 7 | ans=n * (n-1) / 2 * (n-2) / 3 * (n-3) / 4; 8 | printf("%lld\n",ans); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/238/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n; 8 | cin >> n; 9 | if (n < 2 || n > 4) 10 | cout << "Yes" << endl; 11 | else 12 | cout << "No" << endl; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /Contest/NCSummer/Contest_01/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int n, m; 4 | 5 | int main() 6 | { 7 | cin >> n >> m; 8 | if (n == 1 && m == 1) 9 | cout << "Walk Alone\n"; 10 | else 11 | cout << "Kelin\n"; 12 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1720.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | int n; 7 | scanf("%d", &n); 8 | double ans = (pow((1 + sqrt(5)) / 2, n) - pow((1 - sqrt(5)) / 2, n)) / sqrt(5); 9 | printf("%.2lf", ans); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5711.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int x; 6 | scanf("%d", &x); 7 | if ((x % 4 == 0 && x % 100 != 0) || x % 400 == 0) 8 | { 9 | printf("1"); 10 | } 11 | else 12 | { 13 | printf("0"); 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5712.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int x; 6 | scanf("%d", &x); 7 | printf("Today, I ate %d apple", x); 8 | if (x > 1) 9 | { 10 | printf("s."); 11 | } 12 | else 13 | { 14 | printf("."); 15 | } 16 | return 0; 17 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | double Xa, Ya, Xb, Yb; 8 | cin >> Xa >> Ya >> Xb >> Yb; 9 | printf("%.3lf\n", sqrt(pow(Xa - Xb, 2) + pow(Ya - Yb, 2))); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | double x, a, b, c, d; 8 | cin >> x >> a >> b >> c >> d; 9 | printf("%.7lf\n", a * x * x * x + b * x * x + c * x + d); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Contest/Other/HRBUST 2021/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n; 8 | cin >> n; 9 | if (n % 4 == 0) 10 | cout << "bob" << endl; 11 | else 12 | cout << "kiki" << endl; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/269/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b, c, d; 8 | cin >> a >> b >> c >> d; 9 | cout << (a + b) * (c - d) << endl 10 | << "Takahashi" << endl; 11 | return 0; 12 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5713.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int x, a, b; 6 | scanf("%d", &x); 7 | a = 5 * x; 8 | b = 11 + 3 * x; 9 | if (a < b) 10 | { 11 | printf("Local"); 12 | } 13 | else 14 | { 15 | printf("Luogu"); 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_02/C.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | long a; 6 | scanf("%ld", &a); 7 | if(a > 0) 8 | { 9 | printf("positive"); 10 | } 11 | else if(a == 0) 12 | { 13 | printf("zero"); 14 | } 15 | else 16 | { 17 | printf("negative"); 18 | } 19 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/241/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int a[10]; 8 | for (int i = 0; i < 10; i++) 9 | { 10 | cin >> a[i]; 11 | } 12 | cout << a[a[a[0]]] << endl; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1075.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n, ans, a = 2; 6 | scanf("%d", &n); 7 | while (1) 8 | { 9 | if (n % a == 0) 10 | { 11 | ans = n / a; 12 | break; 13 | } 14 | a++; 15 | } 16 | printf("%d", ans); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1425.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int a, b, c, d, e, f; 6 | scanf("%d%d%d%d", &a, &b, &c, &d); 7 | e = c - a; 8 | f = d - b; 9 | if (f < 0) 10 | { 11 | f += 60; 12 | e--; 13 | } 14 | printf("%d %d", e, f); 15 | return 0; 16 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_03/H.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | double a, sum = 0; 7 | for (int i = 0; i < 12; i++) 8 | { 9 | scanf("%lf", &a); 10 | sum += a; 11 | } 12 | printf("$%.2lf", sum / 12); 13 | system("pause"); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5708.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | double a, b, c, p, ans; 7 | scanf("%lf%lf%lf", &a, &b, &c); 8 | p = 0.5 * (a + b + c); 9 | ans = sqrt(p * (p - a) * (p - b) * (p - c)); 10 | printf("%.1lf", ans); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /WHUT/2021/TeamExercise_04/A.py: -------------------------------------------------------------------------------- 1 | T = int(input()) 2 | for i in range(1, T + 1): 3 | nk = input().split() 4 | n = int(nk[0]) 5 | k = int(nk[1]) 6 | ans = 0 7 | for j in range(2, n + 1): 8 | ans += k 9 | ans %= j 10 | print(f"Case {i}: {ans + 1}") 11 | -------------------------------------------------------------------------------- /WHUT/2022/Week01/L.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | double x1, y1, x2, y2; 8 | while (cin >> x1 >> y1 >> x2 >> y2) 9 | printf("%.2lf\n", sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/247/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string arr; 8 | cin >> arr; 9 | cout << '0'; 10 | for (int i = 0; i < 3; i++) 11 | cout << arr[i]; 12 | cout << endl; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/248/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long A, B, K; 8 | cin >> A >> B >> K; 9 | int i; 10 | for (i = 0; A < B; i++) 11 | A *= K; 12 | cout << i << endl; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /LuoGu/2000~2999/B2005.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | char c; 8 | cin >> c; 9 | cout << " " << c << endl 10 | << " " << c << c << c << endl 11 | << c << c << c << c << c << endl; 12 | return 0; 13 | } -------------------------------------------------------------------------------- /LuoGu/2000~2999/B2029.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const double PI = acos(-1.0); 6 | 7 | int main() 8 | { 9 | int h, r; 10 | cin >> h >> r; 11 | double v = PI * r * r * h; 12 | cout << ceil(20000 / v) << endl; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /WHUT/2022/Week01/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin >> n; 9 | while (n--) 10 | { 11 | int a, b; 12 | cin >> a >> b; 13 | cout << a + b << endl; 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/261/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int L1, R1, L2, R2; 8 | cin >> L1 >> R1 >> L2 >> R2; 9 | int ans = min(R1, R2) - max(L1, L2); 10 | cout << (ans > 0 ? ans : 0) << endl; 11 | return 0; 12 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5015.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | char a; 8 | int count = 0; 9 | while (cin >> a) 10 | { 11 | if (isblank(a) == 0) 12 | { 13 | count++; 14 | } 15 | } 16 | cout << count << endl; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /WHUT/2021/TeamExercise_04/H.py: -------------------------------------------------------------------------------- 1 | T = int(input()) 2 | for i in range(1, T + 1): 3 | n = int(input()) 4 | ans = 0 5 | j = 1 6 | while j * j <= n: 7 | ans += 1 8 | if j * j * 2 <= n: 9 | ans += 1 10 | j += 1 11 | print(f"Case {i}: {n - ans}") 12 | -------------------------------------------------------------------------------- /WHUT/2021/Week_08/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n, ans; 8 | cin >> n; 9 | for (int i = 2; i < n; i++) 10 | { 11 | if (n % i == 0) 12 | { 13 | ans = n / i; 14 | break; 15 | } 16 | } 17 | cout << ans; 18 | return 0; 19 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5721.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n, num = 1; 6 | scanf("%d", &n); 7 | for (int i = 0; i < n; i++) 8 | { 9 | for (int j = 0; j < n - i; j++) 10 | { 11 | printf("%02d", num); 12 | num++; 13 | } 14 | printf("\n"); 15 | } 16 | return 0; 17 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_02/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n; 8 | cin >> n; 9 | if (n % 10 <= 4) 10 | { 11 | cout << n - n % 10 << endl; 12 | } 13 | else 14 | { 15 | cout << n + 10 - n % 10 << endl; 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/246/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int A, B; 8 | cin >> A >> B; 9 | double C = sqrt(A * A + B * B); 10 | double cosC = A / C; 11 | cout << cosC << ' ' << sqrt(1 - cosC * cosC); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/265/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int X, Y, N; 8 | cin >> X >> Y >> N; 9 | if (Y < 3 * X) 10 | cout << N / 3 * Y + N % 3 * X << endl; 11 | else 12 | cout << N * X << endl; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_01/F.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int count, input, sum, i; 6 | while(scanf("%d", &count) != EOF) 7 | { 8 | sum = 0; 9 | for(i=0; i 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n, ans; 8 | while (cin >> n) 9 | { 10 | ans = 1; 11 | for (int i = 1; i < n; i++) 12 | { 13 | ans = (ans + 1) * 2; 14 | } 15 | cout << ans << endl; 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/237/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | long long N; 8 | cin >> N; 9 | if (N >= INT32_MIN && N <= INT32_MAX) 10 | { 11 | cout << "Yes" << endl; 12 | } 13 | else 14 | { 15 | cout << "No" << endl; 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Contest/Other/CCNU CaiNiaoBei/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n; 8 | cin >> n; 9 | string str; 10 | cin >> str; 11 | int v[100010]; 12 | for (int i = 0; i < n; i++) 13 | { 14 | cin >> v[i]; 15 | } 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest/7-2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | int n; 11 | double x; 12 | cin >> n >> x; 13 | printf("%d", (int)ceil(1.0 * n / x)); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1914.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | string pwd; 8 | int n; 9 | cin >> n >> pwd; 10 | for (int i = 0; i < pwd.length(); i++) 11 | { 12 | pwd[i] = (char)((pwd[i] - 97 + n) % 26 + 97); 13 | } 14 | cout << pwd; 15 | return 0; 16 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5743.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int cnt(int day) 6 | { 7 | if (day == 1) 8 | return 1; 9 | else 10 | return (cnt(day - 1) + 1) * 2; 11 | } 12 | 13 | int main(void) 14 | { 15 | int n; 16 | cin >> n; 17 | cout << cnt(n) << endl; 18 | return 0; 19 | } -------------------------------------------------------------------------------- /WHUT/2021/Exercise_02-Div2/L.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int T; 8 | cin >> T; 9 | int _T = 1; 10 | while (T--) 11 | { 12 | int N, M; 13 | cin >> N >> M; 14 | 15 | cout << "Case #" << _T++ << ": " << cnt << endl; 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /WHUT/2022/Homework/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | long long a, b; 12 | cin >> a >> b; 13 | cout << a + b << endl; 14 | return 0; 15 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/268/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | set s; 8 | for (int i = 0; i < 5; i++) 9 | { 10 | int t; 11 | cin >> t; 12 | s.insert(t); 13 | } 14 | cout << s.size() << endl; 15 | return 0; 16 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/T.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n; 8 | cin >> n; 9 | double cnt = 0; 10 | while (n--) 11 | { 12 | int t; 13 | cin >> t; 14 | cnt += ceil(1.0 * t / 70); 15 | } 16 | printf("%.1lf\n", cnt * 0.1); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_01/D.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int count, input, sum, i; 6 | while(scanf("%d", &count) != EOF && count) 7 | { 8 | sum = 0; 9 | for(i=0; i 2 | 3 | int main(void) 4 | { 5 | int a, b, sum, day, max = 0; 6 | for (int i = 1; i <= 7; i++) 7 | { 8 | scanf("%d%d", &a, &b); 9 | sum = a + b; 10 | if (max < sum) 11 | { 12 | max = sum; 13 | day = i; 14 | } 15 | } 16 | printf("%d", day); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5739.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | unsigned long long factorial(int x) 6 | { 7 | if (x == 1) 8 | return 1; 9 | else 10 | return x * factorial(x - 1); 11 | } 12 | 13 | int main(void) 14 | { 15 | int n; 16 | cin >> n; 17 | cout << factorial(n); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | map DNA; 8 | DNA['A'] = 'T'; 9 | DNA['T'] = 'A'; 10 | DNA['C'] = 'G'; 11 | DNA['G'] = 'C'; 12 | char c; 13 | while (cin >> c) 14 | { 15 | cout << DNA[c]; 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_02/K.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define PI 3.1415927 4 | 5 | int main() 6 | { 7 | double r, v; 8 | while (scanf("%lf", &r) != EOF) 9 | { 10 | v = 4.0 / 3.0 * PI * r * r * r; 11 | printf("%.3lf\n", v); 12 | } 13 | system("pause"); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1424.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int x, n, ans = 0; 6 | scanf("%d%d", &x, &n); 7 | for (int i = 0; i < n; i++) 8 | { 9 | if (x >= 1 && x <= 5) 10 | { 11 | ans += 250; 12 | } 13 | x++; 14 | if (x == 8) 15 | { 16 | x = 1; 17 | } 18 | } 19 | printf("%d", ans); 20 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5709.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int m, t, s, ans; 6 | scanf("%d%d%d", &m, &t, &s); 7 | if (t == 0) 8 | ans = 0; 9 | else 10 | { 11 | ans = m - s / t; 12 | if (s % t != 0) 13 | ans--; 14 | if (ans <= 0) 15 | ans = 0; 16 | } 17 | printf("%d", ans); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /WHUT/2022/Week02/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | while (cin >> n) 9 | { 10 | long long ans = 1; 11 | for (int i = 1; i < n; i++) 12 | ans = (ans + 1) * 2; 13 | cout << ans << endl; 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/272/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int N; 8 | cin >> N; 9 | long long ans = 0; 10 | while (N--) 11 | { 12 | int t; 13 | cin >> t; 14 | ans += t; 15 | } 16 | cout << ans << endl; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1423.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | double distance, per = 2, swim = 0; 8 | int count; 9 | cin >> distance; 10 | for (count = 0; swim < distance; count++) 11 | { 12 | swim += per; 13 | per *= 0.98; 14 | } 15 | cout << count; 16 | return 0; 17 | } -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest 2023/L1-3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int x1, y1, x2, y2; 8 | cin >> x1 >> y1 >> x2 >> y2; 9 | if (1.0 * y1 / x1 > 1.0 * y2 / x2) 10 | cout << "A" << endl; 11 | else 12 | cout << "B" << endl; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/281/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | int N; 12 | cin >> N; 13 | N++; 14 | while (N--) 15 | cout << N << endl; 16 | return 0; 17 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Regular/144/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long N; 8 | cin >> N; 9 | cout << 2 * N << endl; 10 | if (N % 4) 11 | cout << N % 4; 12 | for (int i = 0; i < N / 4; i++) 13 | cout << 4; 14 | cout << endl; 15 | return 0; 16 | } -------------------------------------------------------------------------------- /LuoGu/4000~4999/P4956.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n, x, k, a; 6 | scanf("%d", &n); 7 | a = n / 364; 8 | for (int i = 100; i > 0; i--) 9 | { 10 | int temp = (a - i) / 3; 11 | if (a - i > 0 && (a - i) % 3 == 0) 12 | { 13 | printf("%d\n%d\n", i, temp); 14 | break; 15 | } 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | char c; 8 | cin >> c; 9 | cout << " " << c << endl 10 | << " " << c << c << c << endl 11 | << c << c << c << c << c << endl 12 | << " " << c << c << c << endl 13 | << " " << c << endl; 14 | return 0; 15 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT05/L1-2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int N, v; 8 | cin >> N >> v; 9 | cout << N / v << endl; 10 | } 11 | 12 | int main() 13 | { 14 | ios::sync_with_stdio(false); 15 | cin.tie(0); 16 | cout.tie(0); 17 | solve(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest Exercise/L1-3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int N; 8 | cin >> N; 9 | if (N >= 90) 10 | cout << "gong xi ni kao le " << N << " fen!" << endl; 11 | else 12 | cout << "kao le " << N << " fen bie xie qi!" << endl; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT01/L1-4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | cout << "2018" << endl 8 | << "wo3 men2 yao4 ying2 !" << endl; 9 | } 10 | 11 | signed main() 12 | { 13 | ios::sync_with_stdio(false); 14 | cin.tie(0); 15 | cout.tie(0); 16 | solve(); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT03/L1-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | cout << "Talk is cheap. Show me the code." << endl; 9 | } 10 | 11 | signed main() 12 | { 13 | ios::sync_with_stdio(false); 14 | cin.tie(0); 15 | cout.tie(0); 16 | solve(); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/279/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | string S, T; 12 | cin >> S >> T; 13 | cout << (S.find(T) != S.npos ? "Yes" : "No") << endl; 14 | return 0; 15 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1427.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int num[110], i; 8 | for (i = 0; i < 100; i++) 9 | { 10 | cin >> num[i]; 11 | if (num[i] == 0) 12 | { 13 | break; 14 | } 15 | } 16 | for (int j = i - 1; j >= 0; j--) 17 | { 18 | cout << num[j] << ' '; 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT04/L1-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | cout << "To iterate is human, to recurse divine." << endl; 9 | } 10 | 11 | signed main() 12 | { 13 | ios::sync_with_stdio(false); 14 | cin.tie(0); 15 | cout.tie(0); 16 | solve(); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/April Fools Day Contest 2023/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | cout << "security" << endl; 9 | } 10 | 11 | signed main() 12 | { 13 | ios::sync_with_stdio(false); 14 | cin.tie(0); 15 | cout.tie(0); 16 | solve(); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1046.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int h[10], r, count = 0; 6 | for (int i = 0; i < 10; i++) 7 | { 8 | scanf("%d", &h[i]); 9 | } 10 | scanf("%d", &r); 11 | for (int i = 0; i < 10; i++) 12 | { 13 | if (r + 30 >= h[i]) 14 | { 15 | count++; 16 | } 17 | } 18 | printf("%d", count); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /LuoGu/2000~2999/P2415.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int s[30]; 8 | int cnt = -1; 9 | while (scanf("%d", &s[++cnt]) != EOF) 10 | ; 11 | long long ans = 0; 12 | for (int i = 0; i < cnt; i++) 13 | { 14 | ans += s[i] * pow(2, cnt - 1); 15 | } 16 | cout << ans << endl; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /WHUT/2022/Week01/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | while (cin >> n, n) 9 | { 10 | int ans = 0, t; 11 | while (n--) 12 | { 13 | cin >> t; 14 | ans += t; 15 | } 16 | cout << ans << endl; 17 | } 18 | return 0; 19 | } -------------------------------------------------------------------------------- /WHUT/2022/Week01/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | while (cin >> n) 9 | { 10 | int ans = 0, t; 11 | while (n--) 12 | { 13 | cin >> t; 14 | ans += t; 15 | } 16 | cout << ans << endl; 17 | } 18 | return 0; 19 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5718.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n, a[100]; 6 | scanf("%d", &n); 7 | for (int i = 0; i < n; i++) 8 | { 9 | scanf("%d", &a[i]); 10 | } 11 | int min = 1001; 12 | for (int i = 0; i < n; i++) 13 | { 14 | if (min > a[i]) 15 | { 16 | min = a[i]; 17 | } 18 | } 19 | printf("%d", min); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_01/E.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int count, input, sum, i, row, j; 6 | scanf("%d", &row); 7 | for(j=0; j 2 | 3 | int main(void) 4 | { 5 | int N, sgn = 0, ans = 0; 6 | scanf("%d", &N); 7 | if (N > 0) 8 | { 9 | sgn = 1; 10 | } 11 | else if (N < 0) 12 | { 13 | N *= -1; 14 | sgn = -1; 15 | } 16 | while (N) 17 | { 18 | ans = ans * 10 + N % 10; 19 | N /= 10; 20 | } 21 | printf("%d", ans * sgn); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_02/H.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | double x1, y1, x2, y2; 8 | double dist; 9 | while (scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2) != EOF) 10 | { 11 | dist = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)); 12 | printf("%.2lf\n", dist); 13 | } 14 | //system("pause"); 15 | return 0; 16 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT02/L1-3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int D; 9 | cin>>D; 10 | cout << (D - 1 + 2) % 7 + 1 << endl; 11 | } 12 | 13 | signed main() 14 | { 15 | ios::sync_with_stdio(false); 16 | cin.tie(0); 17 | cout.tie(0); 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT03/L1-2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int a, b, c; 9 | cin >> a >> b >> c; 10 | cout << a * b * c << endl; 11 | } 12 | 13 | signed main() 14 | { 15 | ios::sync_with_stdio(false); 16 | cin.tie(0); 17 | cout.tie(0); 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/238/_D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int T; 8 | cin >> T; 9 | while (T--) 10 | { 11 | long long a, s; 12 | cin >> a >> s; 13 | long long x = s - 2 * a; 14 | if (x >= 0 && !(x & a)) 15 | cout << "Yes" << endl; 16 | else 17 | cout << "No" << endl; 18 | } 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Contest/Other/ChuanZhiBei 05/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define int long long 3 | 4 | using namespace std; 5 | 6 | int fun(int a, int b) 7 | { 8 | if (b > 0) 9 | return abs(a); 10 | else 11 | return -abs(a); 12 | } 13 | 14 | signed main() 15 | { 16 | int a, b; 17 | cin >> a >> b; 18 | cout << fun(a, b) << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5733.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | string in; 8 | cin >> in; 9 | for (int i = 0; i < in.length(); i++) 10 | { 11 | if (islower(in[i])) 12 | { 13 | printf("%c", in[i] + 'A' - 'a'); 14 | } 15 | else 16 | { 17 | cout << in[i]; 18 | } 19 | } 20 | cout << endl; 21 | return 0; 22 | } -------------------------------------------------------------------------------- /AcWing/800~899/891.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin >> n; 9 | int x = 0; 10 | while (n--) 11 | { 12 | int t; 13 | cin >> t; 14 | x ^= t; 15 | } 16 | if (x) 17 | cout << "Yes" << endl; 18 | else 19 | cout << "No" << endl; 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/253/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector arr(3); 8 | cin >> arr[0] >> arr[1] >> arr[2]; 9 | int tmp = arr[1]; 10 | sort(arr.begin(), arr.end()); 11 | if (tmp == arr[1]) 12 | cout << "Yes" << endl; 13 | else 14 | cout << "No" << endl; 15 | return 0; 16 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/267/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | map mp{ 8 | {"Monday", 5}, 9 | {"Tuesday", 4}, 10 | {"Wednesday", 3}, 11 | {"Thursday", 2}, 12 | {"Friday", 1}}; 13 | string in; 14 | cin >> in; 15 | cout << mp[in] << endl; 16 | return 0; 17 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/April Fools Day Contest 2023/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int n; 9 | cin >> n; 10 | cout << 0 << endl; 11 | } 12 | 13 | signed main() 14 | { 15 | ios::sync_with_stdio(false); 16 | cin.tie(0); 17 | cout.tie(0); 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT02/L1-7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | string s = "I Love GPLT"; 9 | for (auto ele : s) 10 | cout << ele << endl; 11 | } 12 | 13 | signed main() 14 | { 15 | ios::sync_with_stdio(false); 16 | cin.tie(0); 17 | cout.tie(0); 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT04/L1-2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int N, K, M; 9 | cin >> N >> K >> M; 10 | cout << max(0, N - K * M) << endl; 11 | } 12 | 13 | signed main() 14 | { 15 | ios::sync_with_stdio(false); 16 | cin.tie(0); 17 | cout.tie(0); 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/242/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int A, B, C, X; 8 | cin >> A >> B >> C >> X; 9 | double p; 10 | if (X <= A) 11 | p = 1; 12 | else if (A < X && X <= B) 13 | p = 1.0 * C / (B - A); 14 | else 15 | p = 0; 16 | printf("%.9lf", p); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5724.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n, max = -1, min = 1001; 6 | scanf("%d", &n); 7 | for (int i = 0; i < n; i++) 8 | { 9 | int temp; 10 | scanf("%d", &temp); 11 | if (temp > max) 12 | { 13 | max = temp; 14 | } 15 | if (temp < min) 16 | { 17 | min = temp; 18 | } 19 | } 20 | printf("%d", max - min); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_02/E.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int a, b, i, sum; 7 | sum = 0; 8 | scanf("%d%d", &a, &b); 9 | if (a % 2 == 0) 10 | { 11 | a++; 12 | } 13 | for (i = a; i <= b; i = i + 2) 14 | { 15 | sum += i; 16 | } 17 | printf("%d", sum); 18 | //system("pause"); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_08/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n, sum, i; 8 | cin >> n; 9 | sum = (1 + n) * n / 2; 10 | for (i = 2;; i++) 11 | { 12 | if (sum % i == 0) 13 | { 14 | break; 15 | } 16 | } 17 | int ans = sum / i; 18 | cout << ans << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT01/L1-3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int val, off; 8 | cin >> val >> off; 9 | cout << fixed << setprecision(2) << 1.0 * val * off / 10 << endl; 10 | } 11 | 12 | signed main() 13 | { 14 | ios::sync_with_stdio(false); 15 | cin.tie(0); 16 | cout.tie(0); 17 | solve(); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/282/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | int K; 12 | cin >> K; 13 | char c = 'A'; 14 | for (int i = 0; i < K; i++) 15 | cout << char(c + i); 16 | cout << endl; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/276/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string S; 8 | cin >> S; 9 | for (int i = S.size() - 1; i >= 0; i--) 10 | { 11 | if (S[i] == 'a') 12 | { 13 | cout << i + 1 << endl; 14 | return 0; 15 | } 16 | } 17 | cout << -1 << endl; 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/276/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int N; 8 | cin >> N; 9 | vector P(N); 10 | for (int i = 0; i < N; i++) 11 | cin >> P[i]; 12 | prev_permutation(P.begin(), P.end()); 13 | for (int i = 0; i < N; i++) 14 | cout << P[i] << ' '; 15 | cout << endl; 16 | return 0; 17 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/292/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | string S; 8 | cin >> S; 9 | for (auto c : S) 10 | cout << char(toupper(c)); 11 | cout << endl; 12 | } 13 | 14 | int main() 15 | { 16 | ios::sync_with_stdio(false); 17 | cin.tie(0); 18 | cout.tie(0); 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/April Fools Day Contest 2023/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int a, b, c; 9 | cin >> a >> b >> c; 10 | cout << 0 << endl; 11 | } 12 | 13 | signed main() 14 | { 15 | ios::sync_with_stdio(false); 16 | cin.tie(0); 17 | cout.tie(0); 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Contest/Other/HRBUST 2021/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n, A; 8 | cin >> n >> A; 9 | int cnt5 = A / 5, cnt1; 10 | if (cnt5 > n) 11 | { 12 | cnt5 = n; 13 | cnt1 = A - 5 * cnt5; 14 | } 15 | else 16 | { 17 | cnt1 = A - 5 * cnt5; 18 | } 19 | cout << cnt5 << ' ' << cnt1 << endl; 20 | return 0; 21 | } -------------------------------------------------------------------------------- /WHUT/2021/TeamExercise_04/C.py: -------------------------------------------------------------------------------- 1 | T = int(input()) 2 | for i in range(1, T + 1): 3 | nk = input().split() 4 | n = int(nk[0]) 5 | k = int(nk[1]) 6 | ans = 1 7 | if n >= k: 8 | for j in range(0, k): 9 | ans *= (n - j) * (n - j) 10 | for p in range(2, k + 1): 11 | ans //= p 12 | else: 13 | ans = 0 14 | print(f"Case {i}: {ans}") 15 | -------------------------------------------------------------------------------- /WHUT/2022/Homework/R.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | long long n; 12 | cin >> n; 13 | long long ans = 1; 14 | for (int i = 0;i<7;i++) 15 | ans = ans * n % 14; 16 | cout << ans << endl; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/248/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | bool num[10]{}; 8 | string S; 9 | cin >> S; 10 | for (auto ch : S) 11 | { 12 | num[ch - '0'] = true; 13 | } 14 | for (int i = 0; i < 10; i++) 15 | { 16 | if (!num[i]) 17 | cout << i << endl; 18 | } 19 | return 0; 20 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5715.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int a, b, c, t; 6 | scanf("%d%d%d", &a, &b, &c); 7 | if (a > b) 8 | { 9 | t = a; 10 | a = b; 11 | b = t; 12 | } 13 | if (b > c) 14 | { 15 | t = b; 16 | b = c; 17 | c = t; 18 | } 19 | if (a > b) 20 | { 21 | t = a; 22 | a = b; 23 | b = t; 24 | } 25 | printf("%d %d %d", a, b, c); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /WHUT/2022/Train02/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | int n; 12 | cin >> n; 13 | if (n == 1) 14 | cout << -1 << endl; 15 | else 16 | cout << n << ' ' << n + 1 << ' ' << n * (n + 1) << endl; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT01/L1-5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int A, B; 8 | cin >> A >> B; 9 | for (int i = 0; i < A + B; i++) 10 | cout << "Wang!"; 11 | cout << endl; 12 | } 13 | 14 | signed main() 15 | { 16 | ios::sync_with_stdio(false); 17 | cin.tie(0); 18 | cout.tie(0); 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /LuoGu/2000~2999/P2669.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int k; 6 | int n = 1; 7 | int day = 1; 8 | int coin = 0; 9 | scanf("%d", &k); 10 | while (1) 11 | { 12 | for (int i = 0; i < n; i++) 13 | { 14 | coin += n; 15 | day++; 16 | if (day > k) 17 | break; 18 | } 19 | if (day > k) 20 | break; 21 | n++; 22 | } 23 | printf("%d", coin); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /WHUT/2021/Exercise_02-Div2/G.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXSIZE = 1e6; 6 | int S[MAXSIZE]; 7 | 8 | int main(void) 9 | { 10 | int length = 1; 11 | char tmp; 12 | while ((tmp = getchar()) != EOF) 13 | { 14 | if (tmp == '0') 15 | { 16 | S[length++] = -1; 17 | } 18 | else 19 | { 20 | S[length++] = 1; 21 | } 22 | } 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_02/O.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int input, output; 7 | while (scanf("%d", &input) != EOF) 8 | { 9 | output = 1; 10 | for (int i = 1; i < input; i++) 11 | { 12 | output = (output + 1) * 2; 13 | } 14 | printf("%d\n", output); 15 | } 16 | system("pause"); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_09/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int cow(int); 6 | 7 | int main(void) 8 | { 9 | int n; 10 | while (1) 11 | { 12 | cin >> n; 13 | if (!n) 14 | break; 15 | cout << cow(n) << endl; 16 | } 17 | return 0; 18 | } 19 | 20 | int cow(int year) 21 | { 22 | if (year <= 1) 23 | return 1; 24 | else 25 | return cow(year - 1) + cow(year - 3); 26 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5737.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int x, y, cnt = 0; 8 | cin >> x >> y; 9 | stringstream ans; 10 | for (int i = x; i <= y; i++) 11 | { 12 | if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) 13 | { 14 | ans << i << ' '; 15 | cnt++; 16 | } 17 | } 18 | cout << cnt << '\n' 19 | << ans.str() << endl; 20 | return 0; 21 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_09/!E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int N, K, D, X, Y, count = 0; 8 | cin >> N >> K; 9 | while (K--) 10 | { 11 | cin >> D >> X >> Y; 12 | if (X > N || Y > N) 13 | { 14 | count++; 15 | continue; 16 | } 17 | if (D == 2 && X == Y) 18 | { 19 | count++; 20 | continue; 21 | } 22 | } 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /WHUT/2022/Week01/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin >> n; 9 | while (n--) 10 | { 11 | int k; 12 | cin >> k; 13 | int ans = 0, t; 14 | while (k--) 15 | { 16 | cin >> t; 17 | ans += t; 18 | } 19 | cout << ans << endl; 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /WHUT/2022/Week02/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int n; 9 | cin >> n; 10 | while (n--) 11 | { 12 | string s; 13 | cin >> s; 14 | int cnt = 0; 15 | for (auto c : s) 16 | if (isdigit(c)) 17 | cnt++; 18 | cout << cnt << endl; 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/279/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | string s; 12 | cin >> s; 13 | int cnt = 0; 14 | for (int i = 0; i < s.size(); i++) 15 | cnt += s[i] == 'w' ? 2 : 1; 16 | cout << cnt << endl; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Contest/NCSummer/Contest_06/_C.py: -------------------------------------------------------------------------------- 1 | n = m = int(input()) 2 | ans = 0 3 | i = 5 4 | while i <= n: 5 | j = (n - i) // (i * 2) 6 | k = ((n - i) % (i * 2)) // 2 + 1 7 | ans += i * j * (j + 1) // 2 + (j + 1) * k 8 | i *= 5 9 | 10 | i = 10 11 | while i <= n: 12 | j = (n - i) // i 13 | k = ((n - i) % i) // 2 + 1 14 | ans += i * j * (j + 1) // 4 + (j + 1) * k 15 | i *= 5 16 | 17 | print(ans) 18 | -------------------------------------------------------------------------------- /WHUT/2021/TeamExercise_04/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int T; 8 | cin >> T; 9 | for (int i = 1; i <= T; i++) 10 | { 11 | int n, k; 12 | cin >> n >> k; 13 | int ans = 0; 14 | for (int j = 2; j <= n; j++) 15 | { 16 | ans += k; 17 | ans %= j; 18 | } 19 | cout << "Case " << i << ": " << ans + 1 << endl; 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /WHUT/2021/TeamExercise_08/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int price[] = {10, 20, 50, 100}; 6 | int n, ans; 7 | int dp[1010]; 8 | 9 | int main() 10 | { 11 | scanf("%d", &n); 12 | dp[0] = 1; 13 | for (int i = 0; i < 4; i++) 14 | for (int j = price[i]; j <= n; j += 10) 15 | dp[j] += dp[j - price[i]]; 16 | printf("%d\n", dp[n]); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_01/H.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int count, input, sum, i, row, j; 6 | scanf("%d", &row); 7 | for(j=0; j 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | while (cin >> n) 9 | { 10 | long long ans = 1; 11 | while (n--) 12 | { 13 | int t; 14 | cin >> t; 15 | if (t % 2) 16 | ans *= t; 17 | } 18 | cout << ans << endl; 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/293/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | string S; 8 | cin >> S; 9 | for (int i = 0; i < S.size(); i += 2) 10 | swap(S[i], S[i + 1]); 11 | cout << S << endl; 12 | } 13 | 14 | signed main() 15 | { 16 | ios::sync_with_stdio(false); 17 | cin.tie(0); 18 | cout.tie(0); 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Contest/Other/HUSRFC 2023/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | #define int long long 4 | 5 | using namespace std; 6 | 7 | void solve() 8 | { 9 | cout << "Kelin" << endl; 10 | } 11 | 12 | signed main() 13 | { 14 | ios::sync_with_stdio(false); 15 | cin.tie(0); 16 | cout.tie(0); 17 | int t = 1; 18 | // cin >> t; 19 | while (t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1059.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int N; 8 | set num; 9 | cin >> N; 10 | while (N--) 11 | { 12 | int tmp; 13 | cin >> tmp; 14 | num.insert(tmp); 15 | } 16 | cout << num.size() << endl; 17 | for (set::iterator iter = num.begin(); iter != num.end(); ++iter) 18 | { 19 | cout << *iter << ' '; 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1217.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int ticket[20000010]; 6 | 7 | int main(void) 8 | { 9 | std::ios::sync_with_stdio(false); 10 | int n, m; 11 | cin >> n >> m; 12 | for (int i = 0; i < m; i++) 13 | { 14 | cin >> ticket[i]; 15 | } 16 | sort(ticket, ticket + m); 17 | for (int i = 0; i < m; i++) 18 | { 19 | cout << ticket[i] << ' '; 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_03/G.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | double sum = 0; 7 | int num[10]; 8 | for (int i = 0; i < 10; i++) 9 | scanf("%d", &num[i]); 10 | sum = 28.9 * num[0] + 32.7 * num[1] + 45.6 * num[2] + 78 * num[3] + 35 * num[4] + 86.2 * num[5] + 27.8 * num[6] + 43 * num[7] + 56 * num[8] + 65 * num[9]; 11 | printf("%.1lf\n", sum); 12 | system("pause"); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /AcWing/100~199/104.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1e5 + 10; 6 | int N, A[MAXN]; 7 | 8 | int main() 9 | { 10 | cin >> N; 11 | for (int i = 0; i < N; i++) 12 | cin >> A[i]; 13 | sort(A, A + N); 14 | int mid = A[N / 2], ans = 0; 15 | for (int i = 0; i < N; i++) 16 | ans += abs(mid - A[i]); 17 | cout << ans << endl; 18 | return 0; 19 | } -------------------------------------------------------------------------------- /AcWing/800~899/892.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin >> n; 9 | int x = 0; 10 | for (int i = 1; i <= n; i++) 11 | { 12 | int t; 13 | cin >> t; 14 | if (i % 2) 15 | x ^= t; 16 | } 17 | if (x) 18 | cout << "Yes" << endl; 19 | else 20 | cout << "No" << endl; 21 | return 0; 22 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5714.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | double m, n, bmi; 8 | cin >> m >> n; 9 | bmi = m / (n * n); 10 | if (bmi < 18.5) 11 | { 12 | printf("Underweight"); 13 | } 14 | else if (bmi >= 18.5 && bmi < 24) 15 | { 16 | printf("Normal"); 17 | } 18 | else 19 | { 20 | cout << bmi << endl; 21 | printf("Overweight", bmi); 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5716.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int y, m; 6 | int d1[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 7 | int d2[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 8 | scanf("%d%d", &y, &m); 9 | if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) 10 | { 11 | printf("%d", d2[m - 1]); 12 | } 13 | else 14 | { 15 | printf("%d", d1[m - 1]); 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Contest/Other/HRBUST 2021/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n; 8 | cin >> n; 9 | if (n % 2 == 0) 10 | { 11 | while (n) 12 | { 13 | int t = 1; 14 | while (2 * t <= n) 15 | { 16 | t *= 2; 17 | } 18 | cout << t << ' '; 19 | n -= t; 20 | } 21 | } 22 | else 23 | { 24 | cout << "-1"; 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5742.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int N; 8 | cin >> N; 9 | for (int i = 0; i < N; i++) 10 | { 11 | int id, a, b; 12 | cin >> id >> a >> b; 13 | if ((a + b) > 140 && (0.7 * a + 0.3 * b) >= 80) 14 | { 15 | cout << "Excellent" << endl; 16 | } 17 | else 18 | { 19 | cout << "Not excellent" << endl; 20 | } 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest Exercise/L1-4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int N; 8 | cin >> N; 9 | while (N--) 10 | { 11 | int x, y, z; 12 | cin >> x >> y >> z; 13 | if (x * x + y * y + z * z == 3 * x * y * z) 14 | cout << "Yes" << endl; 15 | else 16 | cout << "No" << endl; 17 | } 18 | return 0; 19 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_02/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int N; 8 | cin >> N; 9 | set num; 10 | for (int i = 0; i < N; i++) 11 | { 12 | int t; 13 | cin >> t; 14 | num.insert(t); 15 | } 16 | cout << num.size() << endl; 17 | for (auto it = num.begin(); it != num.end(); ++it) 18 | { 19 | cout << *it << ' '; 20 | } 21 | cout << endl; 22 | return 0; 23 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_02/F.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int a, i, count, num; 7 | count = 0; 8 | scanf("%d", &a); 9 | for (i = 0; i < a; i++) 10 | { 11 | scanf("%d", &num); 12 | if (num % 10 - num / 1000 % 10 - num / 100 % 10 - num / 10 % 10 > 0) 13 | count++; 14 | } 15 | printf("%d", count); 16 | //system("pause"); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_03/F.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int count; 7 | scanf("%d", &count); 8 | int str[count]; 9 | for (int i = 0; i < count; i++) 10 | { 11 | scanf("%d", &str[i]); 12 | } 13 | for (int i = 0; i < count; i++) 14 | { 15 | printf("%d", str[count - i - 1]); 16 | if (i != count - 1) 17 | { 18 | printf(" "); 19 | } 20 | } 21 | system("pause"); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_09/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int stair(int); 6 | 7 | int main(void) 8 | { 9 | int N, M; 10 | cin >> N; 11 | while (N--) 12 | { 13 | cin >> M; 14 | cout << stair(M) << endl; 15 | } 16 | return 0; 17 | } 18 | 19 | int stair(int x) 20 | { 21 | if (x == 1) 22 | return 1; 23 | else if (x == 2) 24 | return 1; 25 | else 26 | return stair(x - 1) + stair(x - 2); 27 | } -------------------------------------------------------------------------------- /WHUT/2022/Week02/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin >> n; 9 | while (n--) 10 | { 11 | double e[3]; 12 | cin >> e[0] >> e[1] >> e[2]; 13 | sort(e, e + 3); 14 | if (e[0] + e[1] - e[2] > 1e-6) 15 | cout << "YES" << endl; 16 | else 17 | cout << "NO" << endl; 18 | } 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/261/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int N; 8 | cin >> N; 9 | map mp; 10 | while (N--) 11 | { 12 | string tmp; 13 | cin >> tmp; 14 | int num = mp[tmp]++; 15 | cout << tmp; 16 | if (num) 17 | cout << '(' << num << ')'; 18 | cout << endl; 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1028.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1010; 6 | long long dp[MAXN]; 7 | 8 | int main() 9 | { 10 | int n; 11 | cin >> n; 12 | for (int i = 1; i <= n; i++) 13 | { 14 | for (int j = 1; j <= i / 2; j++) 15 | { 16 | dp[i] += dp[j]; 17 | } 18 | dp[i]++; 19 | } 20 | cout << dp[n] << endl; 21 | return 0; 22 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1012.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | bool cmp(string a, string b) 6 | { 7 | return a + b > b + a; 8 | } 9 | 10 | int main() 11 | { 12 | int n; 13 | cin >> n; 14 | vector a(n); 15 | for (int i = 0; i < n; i++) 16 | cin >> a[i]; 17 | sort(a.begin(), a.end(), cmp); 18 | for (auto i : a) 19 | cout << i; 20 | cout << endl; 21 | return 0; 22 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1909.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main(void) 8 | { 9 | int need, a, b, c; 10 | int n1, n2, n3, c1, c2, c3; 11 | scanf("%d%d%d%d%d%d%d", &need, &n1, &c1, &n2, &c2, &n3, &c3); 12 | a = ceil(1.0 * need / n1) * c1; 13 | b = ceil(1.0 * need / n2) * c2; 14 | c = ceil(1.0 * need / n3) * c3; 15 | printf("%d", min(a, min(b, c))); 16 | return 0; 17 | } -------------------------------------------------------------------------------- /WHUT/2021/TeamExercise_04/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int T; 8 | cin >> T; 9 | for (int i = 1; i <= T; i++) 10 | { 11 | long long n; 12 | cin >> n; 13 | int ans = 0; 14 | for (long long j = 1; j * j <= n; j++) 15 | { 16 | ans++; 17 | if (j * j * 2 <= n) 18 | ans++; 19 | } 20 | cout << "Case " << i << ": " << n - ans << endl; 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#827 (Div. 4)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int t; 8 | cin >> t; 9 | while (t--) 10 | { 11 | int a[3]; 12 | cin >> a[0] >> a[1] >> a[2]; 13 | sort(a, a + 3); 14 | if (a[0] + a[1] == a[2]) 15 | cout << "Yes" << endl; 16 | else 17 | cout << "No" << endl; 18 | } 19 | return 0; 20 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1428.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n, score[110], num; 8 | cin >> n; 9 | for (int i = 0; i < n; i++) 10 | { 11 | cin >> score[i]; 12 | } 13 | for (int i = 0; i < n; i++) 14 | { 15 | num = 0; 16 | for (int j = 0; j < i; j++) 17 | { 18 | if (score[j] < score[i]) 19 | { 20 | num++; 21 | } 22 | } 23 | cout << num << ' '; 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1980.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n, x, count = 0, num, digit; 6 | scanf("%d%d", &n, &x); 7 | for (int i = 1; i <= n; i++) 8 | { 9 | num = i; 10 | while (num > 9) 11 | { 12 | digit = num % 10; 13 | if (digit == x) 14 | { 15 | count++; 16 | } 17 | num /= 10; 18 | } 19 | if (num == x) 20 | { 21 | count++; 22 | } 23 | } 24 | printf("%d", count); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/P.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int N; 8 | cin >> N; 9 | int num[100]; 10 | int maxn = INT32_MIN; 11 | for (int i = 0; i < N; i++) 12 | { 13 | cin >> num[i]; 14 | maxn = max(maxn, num[i]); 15 | } 16 | int cnt = 0; 17 | for (int i = 0; i < N; i++) 18 | { 19 | if (num[i] != maxn) 20 | cnt += num[i]; 21 | } 22 | cout << cnt; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#839 (Div. 3)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | string s; 9 | cin >> s; 10 | cout << s[0] - '0' + s[2] - '0' << endl; 11 | } 12 | 13 | int main() 14 | { 15 | ios_base::sync_with_stdio(false); 16 | cin.tie(0); 17 | cout.tie(0); 18 | int t; 19 | cin >> t; 20 | while (t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5707.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int s, v, a, b; 6 | scanf("%d%d", &s, &v); 7 | int walk, time, temp; 8 | walk = s / v; 9 | if (s % v != 0) 10 | walk++; 11 | time = walk + 10; 12 | temp = 480 - time; 13 | if (temp >= 0) 14 | { 15 | a = temp / 60; 16 | b = temp % 60; 17 | } 18 | else 19 | { 20 | temp += 1440; 21 | a = temp / 60; 22 | b = temp % 60; 23 | } 24 | printf("%02d:%02d", a, b); 25 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5719.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n, k, sum_a = 0, sum_b = 0, count_a = 0, count_b = 0; 6 | scanf("%d%d", &n, &k); 7 | for (int i = 1; i <= n; i++) 8 | { 9 | if (i % k == 0) 10 | { 11 | sum_a += i; 12 | count_a++; 13 | } 14 | else 15 | { 16 | sum_b += i; 17 | count_b++; 18 | } 19 | } 20 | printf("%.1lf %.1lf", (double)sum_a / count_a, (double)sum_b / count_b); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/G.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int k; 8 | cin >> k; 9 | int c1 = 0, c5 = 0, c10 = 0; 10 | for (int i = 0; i < k; i++) 11 | { 12 | int t; 13 | cin >> t; 14 | if (t == 1) 15 | c1++; 16 | else if (t == 5) 17 | c5++; 18 | else if (t == 10) 19 | c10++; 20 | } 21 | cout << c1 << endl 22 | << c5 << endl 23 | << c10 << endl; 24 | return 0; 25 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_02/D.c: -------------------------------------------------------------------------------- 1 | #include 2 | float f(float x); 3 | 4 | int main() 5 | { 6 | float i, o; 7 | scanf("%f", &i); 8 | o = f(i); 9 | printf("%.3f", o); 10 | return 0; 11 | } 12 | 13 | float f(float x) 14 | { 15 | if(x >= 0 && x < 5 ) 16 | { 17 | return 2.5 - x; 18 | } 19 | else if(x >= 5 && x < 10) 20 | { 21 | return 2 - 1.5 * (x - 3) * (x - 3); 22 | } 23 | else if(x >= 10 && x<20) 24 | { 25 | return 0.5 * x - 1.5; 26 | } 27 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/236/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int N; 8 | cin >> N; 9 | map num; 10 | for (int i = 0; i < 4 * N - 1; i++) 11 | { 12 | int t; 13 | cin >> t; 14 | num[t]++; 15 | } 16 | for (auto it = num.begin(); it != num.end(); ++it) 17 | { 18 | if (it->second != 4) 19 | { 20 | cout << it->first << endl; 21 | break; 22 | } 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/263/_D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | long long N, L, R; 6 | 7 | int main() 8 | { 9 | cin >> N >> L >> R; 10 | long long suml = 0, ans = N * R; 11 | for (int i = 1; i <= N; i++) 12 | { 13 | int tmp; 14 | cin >> tmp; 15 | suml = min(suml + tmp, L * i); 16 | ans = min(ans, suml + (N - i) * R); 17 | } 18 | cout << ans << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/284/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | int N; 12 | cin >> N; 13 | vector S(N); 14 | for (auto &ele : S) 15 | cin >> ele; 16 | reverse(S.begin(), S.end()); 17 | for (auto &ele : S) 18 | cout << ele << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#829 (Div. 2)/_B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int n; 8 | cin >> n; 9 | if (n % 2) 10 | cout << n << ' '; 11 | for (int i = n / 2; i >= 1; i--) 12 | cout << i << ' ' << i + n / 2 << ' '; 13 | cout << endl; 14 | } 15 | 16 | int main() 17 | { 18 | int t; 19 | cin >> t; 20 | while (t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#835 (Div. 4)/_B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int n; 8 | cin >> n; 9 | string s; 10 | cin >> s; 11 | char maxc = 'a'; 12 | for (char &c : s) 13 | maxc = max(maxc, c); 14 | cout << maxc - 'a' + 1 << endl; 15 | } 16 | 17 | int main() 18 | { 19 | int t; 20 | cin >> t; 21 | while (t--) 22 | solve(); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/NCSummer/Contest_01/_D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int n, m; 9 | cin >> n >> m; 10 | if (n == 1 && m == 1) 11 | cout << "Walk Alone" << endl; 12 | else 13 | cout << "Kelin" << endl; 14 | } 15 | 16 | signed main() 17 | { 18 | ios::sync_with_stdio(false); 19 | cin.tie(0); 20 | cout.tie(0); 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Contest/Other/HUSRFC 2023/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | #define int long long 4 | 5 | using namespace std; 6 | 7 | void solve() 8 | { 9 | int n; 10 | cin >> n; 11 | cout << (1 << n) - 1 << endl; 12 | } 13 | 14 | signed main() 15 | { 16 | ios::sync_with_stdio(false); 17 | cin.tie(0); 18 | cout.tie(0); 19 | int t = 1; 20 | // cin >> t; 21 | while (t--) 22 | solve(); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1422.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int amount; 6 | double cost; 7 | scanf("%d", &amount); 8 | if (amount <= 150) 9 | { 10 | cost = 0.4463 * amount; 11 | } 12 | else if (amount > 150 && amount <= 400) 13 | { 14 | cost = 0.4463 * 150 + 0.4663 * (amount - 150); 15 | } 16 | else 17 | { 18 | cost = 0.4463 * 150 + 0.4663 * 250 + 0.5663 * (amount - 400); 19 | } 20 | printf("%.1lf", cost); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_08/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int T; 8 | cin >> T; 9 | while (T--) 10 | { 11 | long long n, B, _B = 1; 12 | cin >> n >> B; 13 | int a = 9971; 14 | while (a != 0) 15 | { 16 | if (a % 2 == 1) 17 | { 18 | _B = _B * B % 9973; 19 | } 20 | B = B * B % 9973; 21 | a >>= 1; 22 | } 23 | cout << (n * (_B + 9973 * 2)) % 9973 << endl; 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1420.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n, curr, last = -10, maxconn = 0, conn = 1; 6 | scanf("%d", &n); 7 | for (int i = 0; i < n; i++) 8 | { 9 | scanf("%d", &curr); 10 | if (last + 1 == curr) 11 | { 12 | conn++; 13 | } 14 | else 15 | { 16 | conn = 1; 17 | } 18 | if (conn > maxconn) 19 | { 20 | maxconn = conn; 21 | } 22 | last = curr; 23 | } 24 | printf("%d", maxconn); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /WHUT/2022/Week04/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | string n; 9 | while (cin >> n, n != "0") 10 | { 11 | int ans = 0; 12 | for (int i = 0; i < n.size(); i++) 13 | { 14 | ans += n[i] - '0'; 15 | if (ans >= 10) 16 | ans = ans % 10 + ans / 10; 17 | } 18 | cout << ans << endl; 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1164.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 110, MAXM = 10010; 6 | int N, M; 7 | int a[MAXN], dp[MAXM]; 8 | 9 | int main() 10 | { 11 | cin >> N >> M; 12 | for (int i = 1; i <= N; i++) 13 | cin >> a[i]; 14 | dp[0] = 1; 15 | for (int i = 1; i <= N; i++) 16 | for (int j = M; j >= 0; j--) 17 | dp[j + a[i]] += dp[j]; 18 | cout << dp[M] << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /LuoGu/2000~2999/P2249.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int num[1000010]; 6 | 7 | int main(void) 8 | { 9 | int n, m; 10 | cin >> n >> m; 11 | for (int i = 0; i < n; i++) 12 | { 13 | cin >> num[i]; 14 | } 15 | while (m--) 16 | { 17 | int q; 18 | cin >> q; 19 | int tmp = lower_bound(num, num + n, q) - num; 20 | if (num[tmp] == q) 21 | cout << tmp + 1 << ' '; 22 | else 23 | cout << "-1 "; 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_02/M.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int a, b; 8 | double c, d; 9 | while (scanf("%d%d", &a, &b) != EOF) 10 | { 11 | d = 0; 12 | c = (double)a; 13 | for (int i = 0; i < b; i++) 14 | { 15 | d += c; 16 | c = sqrt(c); 17 | } 18 | printf("%.2lf\n", d); 19 | } 20 | system("pause"); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /WHUT/2022/Homework/U.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | int n, m; 12 | cin >> n >> m; 13 | long double tmp = sqrt(n) + sqrt(m); 14 | long double res = 1.0; 15 | for (int i = 0; i < 6; i++) 16 | res *= tmp; 17 | cout << fixed << setprecision(0) << res << endl; 18 | return 0; 19 | } -------------------------------------------------------------------------------- /WHUT/2022/Week02/G.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int f(char c) 6 | { 7 | if (isupper(c)) 8 | return c - 'A' + 1; 9 | else 10 | return -(c - 'a' + 1); 11 | } 12 | 13 | int main() 14 | { 15 | int t; 16 | cin >> t; 17 | while (t--) 18 | { 19 | char c; 20 | int n; 21 | cin >> c >> n; 22 | getchar(); 23 | cout << n + f(c) << endl; 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/250/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int H, W, R, C; 8 | cin >> H >> W >> R >> C; 9 | int ans = 0; 10 | if (0 < R + 1 && R + 1 <= H) 11 | ans++; 12 | if (0 < R - 1 && R - 1 <= H) 13 | ans++; 14 | if (0 < C + 1 && C + 1 <= W) 15 | ans++; 16 | if (0 < C - 1 && C - 1 <= W) 17 | ans++; 18 | cout << ans << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/274/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 4e5 + 20; 6 | int N, A[MAXN]; 7 | int dist[MAXN]; 8 | 9 | int main() 10 | { 11 | cin >> N; 12 | for (int i = 1; i <= N; i++) 13 | cin >> A[i]; 14 | for (int i = 1; i <= N; i++) 15 | dist[2 * i] = dist[2 * i + 1] = dist[A[i]] + 1; 16 | for (int i = 1; i <= 2 * N + 1; i++) 17 | cout << dist[i] << endl; 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Contest/Other/HRBUST 2021/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int x[1000010]; 6 | 7 | int main(void) 8 | { 9 | int L, n; 10 | cin >> L >> n; 11 | for (int i = 0; i < n; i++) 12 | { 13 | cin >> x[i]; 14 | } 15 | // min 16 | int mint = 0; 17 | for (int i = 0; i < n; i++) 18 | { 19 | mint = max(mint, min(x[i], L - x[i])); 20 | } 21 | cout << mint << ' '; 22 | //max 23 | int maxt = 0; 24 | return 0; 25 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1116.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1e4 + 10; 6 | int N, a[MAXN]; 7 | 8 | int main() 9 | { 10 | cin >> N; 11 | for (int i = 0; i < N; i++) 12 | cin >> a[i]; 13 | int ans = 0; 14 | for (int i = 0; i < N; i++) 15 | for (int j = i + 1; j < N; j++) 16 | if (a[i] > a[j]) 17 | swap(a[i], a[j]), ans++; 18 | cout << ans << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5726.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n, max = -1, min = 11, sum = 0; 6 | double ans; 7 | scanf("%d", &n); 8 | for (int i = 0; i < n; i++) 9 | { 10 | int temp; 11 | scanf("%d", &temp); 12 | sum += temp; 13 | if (temp > max) 14 | { 15 | max = temp; 16 | } 17 | if (temp < min) 18 | { 19 | min = temp; 20 | } 21 | } 22 | ans = 1.0 * (sum - max - min) / (n - 2); 23 | printf("%.2lf", ans); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT05/L1-4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int a, b; 9 | cin >> a >> b; 10 | int c = a + b; 11 | long long ans = 1LL; 12 | for (int i = 2; i <= c; i++) 13 | ans *= i; 14 | cout << ans << endl; 15 | } 16 | 17 | int main() 18 | { 19 | ios::sync_with_stdio(false); 20 | cin.tie(0); 21 | cout.tie(0); 22 | solve(); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/280/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | int N; 12 | cin >> N; 13 | vector S(N + 1); 14 | for (int i = 1; i <= N; i++) 15 | cin >> S[i]; 16 | for (int i = 1; i <= N; i++) 17 | cout << S[i] - S[i - 1] << ' '; 18 | cout << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/April Fools Day Contest 2023/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int n; 9 | cin >> n; 10 | if (n == 15 || n == 20 || n == 21) 11 | cout << "NO" << endl; 12 | else 13 | cout << "YES" << endl; 14 | } 15 | 16 | signed main() 17 | { 18 | ios::sync_with_stdio(false); 19 | cin.tie(0); 20 | cout.tie(0); 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /WHUT/2022/Week01/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin >> n; 9 | for (int i = 0; i < n; i++) 10 | { 11 | if (i) 12 | cout << endl; 13 | int k; 14 | cin >> k; 15 | int ans = 0, t; 16 | while (k--) 17 | { 18 | cin >> t; 19 | ans += t; 20 | } 21 | cout << ans << endl; 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/242/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | string S; 8 | cin >> S; 9 | map m; 10 | for (int i = 0; i < S.length(); i++) 11 | m[S[i]]++; 12 | for (auto it = m.begin(); it != m.end(); ++it) 13 | { 14 | for (int i = 0; i < it->second; i++) 15 | { 16 | cout << it->first; 17 | } 18 | } 19 | cout << endl; 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/253/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | long long N, A, B; 8 | cin >> N >> A >> B; 9 | long long C = A * B / __gcd(A, B); 10 | long long N_A = N / A, N_B = N / B, N_C = N / C; 11 | cout << N * (N + 1) / 2 - 12 | N_A * (N_A + 1) / 2 * A - 13 | N_B * (N_B + 1) / 2 * B + 14 | N_C * (N_C + 1) / 2 * C 15 | << endl; 16 | return 0; 17 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1319.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n, count = 0; 8 | bool is_one = false; 9 | cin >> n; 10 | while (1) 11 | { 12 | if (count == n * n) 13 | break; 14 | int a; 15 | cin >> a; 16 | for (int i = 0; i < a; i++) 17 | { 18 | printf("%d", is_one); 19 | count++; 20 | if (count % n == 0) 21 | cout << endl; 22 | } 23 | is_one = (is_one) ? false : true; 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#836 (Div. 2)/_A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | string s; 9 | cin >> s; 10 | cout << s; 11 | reverse(s.begin(), s.end()); 12 | cout << s << endl; 13 | } 14 | 15 | int main() 16 | { 17 | ios_base::sync_with_stdio(false); 18 | cin.tie(0); 19 | cout.tie(0); 20 | int t; 21 | cin >> t; 22 | while (t--) 23 | solve(); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/268/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | string S, T; 8 | cin >> S >> T; 9 | if (S.size() > T.size()) 10 | { 11 | cout << "No" << endl; 12 | return 0; 13 | } 14 | for (int i = 0; i < S.size(); i++) 15 | if (S[i] != T[i]) 16 | { 17 | cout << "No" << endl; 18 | return 0; 19 | } 20 | cout << "Yes" << endl; 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#834 (Div. 3)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | string s; 8 | cin >> s; 9 | string t; 10 | for (int i = 0; i < 20; i++) 11 | t += "Yes"; 12 | if (t.find(s) != t.npos) 13 | cout << "YES" << endl; 14 | else 15 | cout << "NO" << endl; 16 | } 17 | 18 | int main() 19 | { 20 | int t; 21 | cin >> t; 22 | while (t--) 23 | solve(); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#835 (Div. 4)/_A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int num[3]; 7 | 8 | void solve() 9 | { 10 | cin >> num[0] >> num[1] >> num[2]; 11 | sort(num, num + 3); 12 | cout << num[1] << endl; 13 | } 14 | 15 | int main() 16 | { 17 | ios_base::sync_with_stdio(false); 18 | cin.tie(0); 19 | cout.tie(0); 20 | int t; 21 | cin >> t; 22 | while (t--) 23 | solve(); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /WHUT/2022/Train02/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int n; 9 | cin >> n; 10 | int _; 11 | for (int i = 0; i < n; i++) 12 | cin >> _; 13 | cout << 1 << ' ' << n << endl; 14 | } 15 | 16 | int main() 17 | { 18 | ios_base::sync_with_stdio(false); 19 | cin.tie(0); 20 | cout.tie(0); 21 | int t; 22 | cin >> t; 23 | while (t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/247/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void print(int n) 6 | { 7 | if (n == 1) 8 | { 9 | cout << 1 << ' '; 10 | return; 11 | } 12 | else 13 | { 14 | print(n - 1); 15 | cout << n << ' '; 16 | print(n - 1); 17 | } 18 | } 19 | 20 | int main() 21 | { 22 | ios::sync_with_stdio(false); 23 | cin.tie(0); 24 | int N; 25 | cin >> N; 26 | print(N); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/256/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | long long fast_pow(long long a, long long b) 6 | { 7 | long long res = 1; 8 | while (b) 9 | { 10 | if (b & 1) 11 | { 12 | res = res * a; 13 | } 14 | a = a * a; 15 | b >>= 1; 16 | } 17 | return res; 18 | } 19 | 20 | int main() 21 | { 22 | int N; 23 | cin >> N; 24 | cout << fast_pow(2, N) << endl; 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Contest/Other/CCNU CaiNiaoBei/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int T; 8 | cin >> T; 9 | while (T--) 10 | { 11 | int X, Y, Z; 12 | cin >> X >> Y >> Z; 13 | double ha, he; 14 | ha = 1.0 * min(X, Y) / 2; 15 | he = 1.0 * Z / 2; 16 | if (ha > he) 17 | cout << "xiaoha" << endl; 18 | else if (ha < he) 19 | cout << "xiaohe" << endl; 20 | else 21 | cout << "ping" << endl; 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1088_2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1e4 + 10; 6 | int n, m; 7 | int a[MAXN]; 8 | 9 | int main() 10 | { 11 | cin >> n >> m; 12 | for (int i = 0; i < n; i++) 13 | cin >> a[i]; 14 | while (m--) 15 | next_permutation(a, a + n); 16 | for (int i = 0; i < n; i++) 17 | { 18 | if (i) 19 | cout << ' '; 20 | cout << a[i]; 21 | } 22 | cout << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/R.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int num[10]; 8 | for (int i = 0; i < 10; i++) 9 | { 10 | cin >> num[i]; 11 | } 12 | sort(num, num + 10); 13 | for (int i = 9; i >= 0; i--) 14 | { 15 | if (num[i] % 2) 16 | { 17 | cout << num[i] << ' '; 18 | } 19 | } 20 | for (int i = 0; i < 10; i++) 21 | { 22 | if (!(num[i] % 2)) 23 | { 24 | cout << num[i] << ' '; 25 | } 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /WHUT/2021/Exercise_02-Div2/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int N; 8 | cin >> N; 9 | long long sum[50010]; 10 | cin >> sum[1]; 11 | for (int i = 2; i <= N; i++) 12 | { 13 | int tmp; 14 | cin >> tmp; 15 | sum[i] = sum[i - 1] + tmp; 16 | } 17 | int Q; 18 | cin >> Q; 19 | for (int t = 1; t <= Q; t++) 20 | { 21 | int i, l; 22 | cin >> i >> l; 23 | cout << sum[i + l - 1] - sum[i - 1] << endl; 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /WHUT/2022/Week04/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int t; 8 | cin >> t; 9 | while (t--) 10 | { 11 | string str; 12 | cin >> str; 13 | int cnt[3]{}; 14 | for (int i = 0; i < str.size(); i++) 15 | cnt[str[i] - 'A']++; 16 | if (cnt[0] + cnt[2] == cnt[1]) 17 | cout << "YES" << endl; 18 | else 19 | cout << "NO" << endl; 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT02/L1-4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | string a; 9 | int b, c; 10 | cin >> a >> b >> c; 11 | if (!(15 <= b && b <= 20 && 50 <= c && c <= 70)) 12 | cout << a << endl; 13 | } 14 | 15 | signed main() 16 | { 17 | ios::sync_with_stdio(false); 18 | cin.tie(0); 19 | cout.tie(0); 20 | int t; 21 | cin >> t; 22 | while (t--) 23 | solve(); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT02/L1-5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int A, B; 9 | cin >> A >> B; 10 | int ans = A * B; 11 | string out = to_string(ans); 12 | reverse(out.begin(), out.end()); 13 | int out_int = stoi(out); 14 | cout << out_int << endl; 15 | } 16 | 17 | signed main() 18 | { 19 | ios::sync_with_stdio(false); 20 | cin.tie(0); 21 | cout.tie(0); 22 | solve(); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /AcWing/700~799/790.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const double eps = 1e-9; 6 | 7 | int main() 8 | { 9 | double num; 10 | cin >> num; 11 | double l, r; 12 | l = -10000, r = 10000; 13 | while (r - l > eps) 14 | { 15 | double mid = (l + r) / 2; 16 | if (mid * mid * mid >= num) 17 | r = mid; 18 | else 19 | l = mid; 20 | } 21 | cout << fixed << setprecision(6) << l << endl; 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/245/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | bool num[2020]; 6 | 7 | int main(void) 8 | { 9 | int N; 10 | cin >> N; 11 | for (int i = 0; i < N; i++) 12 | { 13 | int t; 14 | cin >> t; 15 | num[t] = true; 16 | } 17 | for (int i = 0; i <= 2000; i++) 18 | { 19 | if (!num[i]) 20 | { 21 | cout << i << endl; 22 | break; 23 | } 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1200.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int trans(string); 6 | 7 | int main(void) 8 | { 9 | string a, b; 10 | cin >> a >> b; 11 | if (trans(a) == trans(b)) 12 | { 13 | cout << "GO" << endl; 14 | } 15 | else 16 | { 17 | cout << "STAY" << endl; 18 | } 19 | return 0; 20 | } 21 | 22 | int trans(string a) 23 | { 24 | int ans = 1; 25 | for (int i = 0; i < a.length(); i++) 26 | { 27 | ans *= a[i] - 'A' + 1; 28 | } 29 | return ans % 47; 30 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5727.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int num[1010], i; 8 | cin >> num[0]; 9 | for (i = 1; i < 1000; i++) 10 | { 11 | if (num[i - 1] == 1) 12 | { 13 | break; 14 | } 15 | if (num[i - 1] % 2 == 0) 16 | { 17 | num[i] = num[i - 1] / 2; 18 | } 19 | else 20 | { 21 | num[i] = num[i - 1] * 3 + 1; 22 | } 23 | } 24 | for (int j = i - 1; j >= 0; j--) 25 | { 26 | cout << num[j] << ' '; 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1554.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int M, N, digit[10] = {0}; 8 | cin >> M >> N; 9 | for (int i = M; i <= N;i++) 10 | { 11 | int num = i; 12 | while(num) 13 | { 14 | digit[num % 10]++; 15 | num /= 10; 16 | } 17 | } 18 | for (int i = 0; i < 10;i++) 19 | { 20 | cout << digit[i] << " "; 21 | } 22 | cout << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/279/D.py: -------------------------------------------------------------------------------- 1 | from decimal import * 2 | getcontext().prec = 50 3 | 4 | [A, B] = map(lambda x: int(x), input().split(' ')) 5 | 6 | 7 | def f(x: Decimal) -> Decimal: 8 | return Decimal(A) / (x + Decimal(1)).sqrt() + Decimal(B) * x 9 | 10 | 11 | l = 0 12 | r = A 13 | while l < r: 14 | m1 = l + (r - l) // 3 15 | m2 = r - (r - l) // 3 16 | if f(Decimal(m1)) > f(Decimal(m2)): 17 | l = m1 + 1 18 | else: 19 | r = m2 - 1 20 | 21 | print(round(f(Decimal(l)), 10)) 22 | -------------------------------------------------------------------------------- /Contest/Codeforces/Other/Educational #137 (Rated for Div. 2)/_A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | inline int comb(int a) 6 | { 7 | return a * (a - 1) / 2; 8 | } 9 | 10 | void solve() 11 | { 12 | int n; 13 | cin >> n; 14 | int t; 15 | for (int i = 0; i < n; i++) 16 | cin >> t; 17 | cout << 6 * comb(10 - n) << endl; 18 | } 19 | 20 | int main() 21 | { 22 | int t; 23 | cin >> t; 24 | while (t--) 25 | solve(); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5744.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int improve(int grade) 6 | { 7 | int tmp = grade * 1.2; 8 | if (tmp >= 600) 9 | { 10 | return 600; 11 | } 12 | else 13 | { 14 | return tmp; 15 | } 16 | } 17 | 18 | int main(void) 19 | { 20 | int n; 21 | cin >> n; 22 | string name; 23 | int age, grade; 24 | while (n--) 25 | { 26 | cin >> name >> age >> grade; 27 | cout << name << ' ' << age + 1 << ' ' << improve(grade) << endl; 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Misc/Completebag_Optimized_2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int SIZE = 1010; 7 | int N, V; 8 | int v[SIZE], w[SIZE]; 9 | int dp[SIZE]; 10 | 11 | int main() 12 | { 13 | cin >> N >> V; 14 | for (int i = 1; i <= N; i++) 15 | cin >> v[i] >> w[i]; 16 | for (int i = 1; i <= N; i++) 17 | for (int j = v[i]; j <= V; j++) 18 | dp[j] = max(dp[j], dp[j - v[i]] + w[i]); 19 | cout << dp[V] << endl; 20 | return 0; 21 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_08/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int gcd(int, int); 6 | int lcm(int, int); 7 | 8 | int main(void) 9 | { 10 | int a, b; 11 | while (cin >> a >> b) 12 | { 13 | cout << gcd(a, b) << " " << lcm(a, b) << endl; 14 | } 15 | return 0; 16 | } 17 | 18 | int gcd(int a, int b) 19 | { 20 | if (b != 0) 21 | { 22 | return gcd(b, a % b); 23 | } 24 | else 25 | { 26 | return a; 27 | } 28 | } 29 | 30 | int lcm(int a, int b) 31 | { 32 | return a / gcd(a, b) * b; 33 | } -------------------------------------------------------------------------------- /AcWing/700~799/795.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1e5 + 10; 6 | int n, m; 7 | int ls[MAXN], psls[MAXN]; 8 | 9 | int main() 10 | { 11 | cin >> n >> m; 12 | for (int i = 1; i <= n; i++) 13 | cin >> ls[i]; 14 | for (int i = 1; i <= n; i++) 15 | psls[i] = psls[i - 1] + ls[i]; 16 | while (m--) 17 | { 18 | int l, r; 19 | cin >> l >> r; 20 | cout << psls[r] - psls[l - 1] << endl; 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /AcWing/800~899/872.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int gcd(int a, int b) 6 | { 7 | if (b != 0) 8 | return gcd(b, a % b); 9 | else 10 | return a; 11 | } 12 | 13 | /* inline int lcm(int a, int b) 14 | { 15 | return a / gcd(a, b) * b; 16 | } */ 17 | 18 | int main() 19 | { 20 | int n; 21 | cin >> n; 22 | while (n--) 23 | { 24 | int a, b; 25 | cin >> a >> b; 26 | cout << gcd(a, b) << endl; 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/280/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | string S, T; 12 | cin >> S >> T; 13 | for (int i = 0; i < S.size(); i++) 14 | { 15 | if (S[i] != T[i]) 16 | { 17 | cout << i + 1 << endl; 18 | return 0; 19 | } 20 | } 21 | cout << S.size() + 1 << endl; 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/Global Round #24/_A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int n; 9 | cin >> n; 10 | int _; 11 | for (int i = 0; i < n; i++) 12 | cin >> _; 13 | cout << 1 << ' ' << n << endl; 14 | } 15 | 16 | int main() 17 | { 18 | ios_base::sync_with_stdio(false); 19 | cin.tie(0); 20 | cout.tie(0); 21 | int t; 22 | cin >> t; 23 | while (t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/Nebius Welcome Round (Div. 1 + Div. 2)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int a, b; 8 | cin >> a >> b; 9 | a = abs(a); 10 | b = abs(b); 11 | cout << 2 * min(a, b) + max(2 * abs(a - b) - 1, 0) << endl; 12 | } 13 | 14 | signed main() 15 | { 16 | ios::sync_with_stdio(false); 17 | cin.tie(0); 18 | cout.tie(0); 19 | int t; 20 | cin >> t; 21 | while (t--) 22 | solve(); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /WHUT/2022/Week03/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int N; 8 | cin >> N; 9 | bool flag = false; 10 | for (int i = sqrt(2 * N); i > 1; i--) 11 | { 12 | if (2 * N - i * (i - 1) > 0 && !((2 * N - i * (i - 1)) % (2 * i))) 13 | { 14 | flag = true; 15 | cout << (2 * N - i * (i - 1)) / (2 * i) << endl; 16 | } 17 | } 18 | if (!flag) 19 | cout << "No Solution" << endl; 20 | return 0; 21 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT04/L1-4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int N, M; 9 | cin >> N >> M; 10 | while (N--) 11 | { 12 | double p; 13 | cin >> p; 14 | if (p < M) 15 | cout << "On Sale! " << fixed << setprecision(1) << p << endl; 16 | } 17 | } 18 | 19 | signed main() 20 | { 21 | ios::sync_with_stdio(false); 22 | cin.tie(0); 23 | cout.tie(0); 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Regular/144/B_TLE.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define int long long 3 | 4 | using namespace std; 5 | 6 | const int MAXN = 3e5 + 20; 7 | int N, a, b; 8 | int A[MAXN]; 9 | 10 | signed main() 11 | { 12 | cin >> N >> a >> b; 13 | for (int i = 0; i < N; i++) 14 | cin >> A[i]; 15 | sort(A, A + N); 16 | while (A[N - 1] - b >= A[0]) 17 | { 18 | A[0] += a; 19 | A[N - 1] -= b; 20 | sort(A, A + N); 21 | } 22 | cout << A[0] << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#859 (Div. 4)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int a, b, c; 9 | cin >> a >> b >> c; 10 | if (a + b == c) 11 | cout << "+" << endl; 12 | else 13 | cout << "-" << endl; 14 | } 15 | 16 | signed main() 17 | { 18 | ios::sync_with_stdio(false); 19 | cin.tie(0); 20 | cout.tie(0); 21 | int t; 22 | cin >> t; 23 | while (t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /LuoGu/2000~2999/B2124.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | #define int long long 4 | 5 | using namespace std; 6 | 7 | void solve() 8 | { 9 | string s; 10 | cin >> s; 11 | string t = s; 12 | reverse(t.begin(), t.end()); 13 | cout << (s == t ? "yes" : "no") << endl; 14 | } 15 | 16 | signed main() 17 | { 18 | ios::sync_with_stdio(false); 19 | cin.tie(0); 20 | cout.tie(0); 21 | int t = 1; 22 | // cin >> t; 23 | while (t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_03/L.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int dim, result = 0, temp; 7 | scanf("%d", &dim); 8 | int value1[dim], value2[dim]; 9 | for (int i = 0; i < dim; i++) 10 | { 11 | scanf("%d", &value1[i]); 12 | } 13 | for (int i = 0; i < dim; i++) 14 | { 15 | scanf("%d", &value2[i]); 16 | } 17 | for (int i = 0; i < dim; i++) 18 | { 19 | temp = value1[i] * value2[i]; 20 | result += temp; 21 | } 22 | printf("%d", result); 23 | system("pause"); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /WHUT/2022/Week03/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | set s; 6 | void init() 7 | { 8 | for (int i = 1; i <= 1000; i++) 9 | for (int j = 1; j < i; j++) 10 | s.insert(i * i - j * j); 11 | } 12 | 13 | int main() 14 | { 15 | init(); 16 | int n; 17 | cin >> n; 18 | for (auto i : s) 19 | { 20 | n--; 21 | if (!n) 22 | { 23 | cout << i << endl; 24 | break; 25 | } 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/245/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int A, B, C, D; 8 | cin >> A >> B >> C >> D; 9 | if (A < C) 10 | { 11 | cout << "Takahashi" << endl; 12 | } 13 | else if (A == C) 14 | { 15 | if (B <= D) 16 | cout << "Takahashi" << endl; 17 | else 18 | cout << "Aoki" << endl; 19 | } 20 | else 21 | { 22 | cout << "Aoki" << endl; 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/274/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1010; 6 | int H, W; 7 | int cnt[MAXN]; 8 | 9 | int main() 10 | { 11 | cin >> H >> W; 12 | for (int i = 0; i < H; i++) 13 | { 14 | string s; 15 | cin >> s; 16 | for (int j = 0; j < W; j++) 17 | if (s[j] == '#') 18 | cnt[j]++; 19 | } 20 | for (int i = 0; i < W; i++) 21 | cout << cnt[i] << ' '; 22 | cout << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/Code TON #3 (Div. 1 + Div. 2)/_A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int n; 8 | cin >> n; 9 | int first, temp; 10 | cin >> first; 11 | for (int i = 1; i < n; i++) 12 | cin >> temp; 13 | if (first == 1) 14 | cout << "Yes" << endl; 15 | else 16 | cout << "No" << endl; 17 | } 18 | 19 | int main() 20 | { 21 | int t; 22 | cin >> t; 23 | while (t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/Educational #138 (Rated for Div. 2)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 10; 6 | 7 | void solve() 8 | { 9 | int n, m, x, y; 10 | cin >> n >> m; 11 | for (int i = 0; i < m; i++) 12 | cin >> x >> y; 13 | if (m < n) 14 | cout << "YES" << endl; 15 | else 16 | cout << "NO" << endl; 17 | } 18 | 19 | int main() 20 | { 21 | int t; 22 | cin >> t; 23 | while (t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/Educational #152 (Rated for Div. 2)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | // #define int long long 4 | 5 | using namespace std; 6 | 7 | void solve() 8 | { 9 | int b, c, h; 10 | cin >> b >> c >> h; 11 | cout << min(2 * b - 1, 2 * (c + h) + 1) << endl; 12 | } 13 | 14 | signed main() 15 | { 16 | ios::sync_with_stdio(false); 17 | cin.tie(0); 18 | cout.tie(0); 19 | int t = 1; 20 | cin >> t; 21 | while (t--) 22 | solve(); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#832 (Div. 2)/_C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int n; 8 | cin >> n; 9 | vector a(n); 10 | for (int i = 0; i < n; i++) 11 | cin >> a[i]; 12 | if (*min_element(a.begin(), a.end()) == a.front()) 13 | cout << "Bob" << endl; 14 | else 15 | cout << "Alice" << endl; 16 | } 17 | 18 | int main() 19 | { 20 | int t; 21 | cin >> t; 22 | while (t--) 23 | solve(); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5732.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n, mat[20][20]{1}; 8 | cin >> n; 9 | for (int i = 1; i < n; i++) 10 | { 11 | mat[i][0] = 1; 12 | for (int j = 1; j < i; j++) 13 | { 14 | mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j]; 15 | } 16 | mat[i][i] = 1; 17 | } 18 | for (int i = 0; i < n; i++) 19 | { 20 | for (int j = 0; j < i + 1; j++) 21 | { 22 | cout << mat[i][j] << ' '; 23 | } 24 | cout << endl; 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_08/G.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int T; 8 | cin >> T; 9 | while (T--) 10 | { 11 | long long N, t, x = 1; 12 | cin >> N; 13 | t = N; 14 | while (t != 0) 15 | { 16 | if (t % 2 == 1) 17 | { 18 | x = x * N % 10; 19 | } 20 | N = N * N % 10; 21 | t >>= 1; 22 | } 23 | cout << x << endl; 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /AcWing/800~899/830.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1e5 + 10; 6 | int N; 7 | int num[MAXN]; 8 | int st[MAXN], idx = 0; 9 | 10 | int main() 11 | { 12 | cin >> N; 13 | for (int i = 0; i < N; i++) 14 | cin >> num[i]; 15 | for (int i = 0; i < N; i++) 16 | { 17 | while (idx && st[idx] >= num[i]) 18 | idx--; 19 | cout << (idx ? st[idx] : -1) << ' '; 20 | st[++idx] = num[i]; 21 | } 22 | cout << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/Educational #137 (Rated for Div. 2)/_B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int n; 8 | cin >> n; 9 | for (int i = 1; i <= n; i++) 10 | if (i % 2) 11 | cout << i << ' '; 12 | for (int i = n; i >= 1; i--) 13 | if (!(i % 2)) 14 | cout << i << ' '; 15 | cout << endl; 16 | } 17 | 18 | int main() 19 | { 20 | int t; 21 | cin >> t; 22 | while (t--) 23 | solve(); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#832 (Div. 2)/_B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int n; 8 | cin >> n; 9 | int t = n / 2; 10 | cout << t + n % 2 << endl; 11 | for (int i = 0; i < t; i++) 12 | cout << i * 3 + 1 << ' ' << (n - i) * 3 << endl; 13 | if (n % 2) 14 | cout << t * 3 + 1 << ' ' << t * 3 + 3 << endl; 15 | } 16 | 17 | int main() 18 | { 19 | int t; 20 | cin >> t; 21 | while (t--) 22 | solve(); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/Other/CCNU CaiNiaoBei/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int step(int x) 6 | { 7 | int res = 0; 8 | while (1) 9 | { 10 | if (x > 3) 11 | { 12 | res++; 13 | x -= 3; 14 | } 15 | else 16 | { 17 | res++; 18 | break; 19 | } 20 | } 21 | return res; 22 | } 23 | 24 | int main(void) 25 | { 26 | int t; 27 | cin >> t; 28 | while (t--) 29 | { 30 | int x; 31 | cin >> x; 32 | cout << step(abs(x)) << endl; 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /LuoGu/2000~2999/P2241.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, m; 8 | cin >> n >> m; 9 | if (m > n) 10 | swap(n, m); 11 | long long sq = 0, rc = 0; 12 | for (int i = 1; i <= n; i++) 13 | for (int j = 1; j <= m; j++) 14 | if (i == j) 15 | sq += 1LL * (n + 1 - i) * (m + 1 - j); 16 | else 17 | rc += 1LL * (n + 1 - i) * (m + 1 - j); 18 | cout << sq << ' ' << rc << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/236/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | string S[100010]; 6 | 7 | int main(void) 8 | { 9 | ios::sync_with_stdio(false); 10 | int N, M; 11 | cin >> N >> M; 12 | for (int i = 0; i < N; i++) 13 | { 14 | cin >> S[i]; 15 | } 16 | string tmp; 17 | cin >> tmp; 18 | for (int i = 0; i < N; i++) 19 | { 20 | if (S[i] == tmp) 21 | { 22 | cout << "Yes" << endl; 23 | cin >> tmp; 24 | } 25 | else 26 | { 27 | cout << "No" << endl; 28 | } 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/280/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | int H, W; 12 | cin >> H >> W; 13 | int ans = 0; 14 | for (int i = 0; i < H; i++) 15 | { 16 | string s; 17 | cin >> s; 18 | for (int j = 0; j < W; j++) 19 | if (s[j] == '#') 20 | ans++; 21 | } 22 | cout << ans << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/283/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | string S; 12 | cin >> S; 13 | int dbzero = 0; 14 | for (int i = 0; i < S.size(); i++) 15 | { 16 | if (S[i] == '0' && S[i + 1] == '0') 17 | { 18 | dbzero++; 19 | i++; 20 | } 21 | } 22 | cout << S.size() - dbzero << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/Other/WHU 2023/L.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | #define int long long 4 | 5 | using namespace std; 6 | 7 | void solve() 8 | { 9 | int x; 10 | cin >> x; 11 | int len = __lg(x); 12 | int ans = 2; 13 | while (len--) 14 | ans *= 2; 15 | cout << ans << endl; 16 | } 17 | 18 | signed main() 19 | { 20 | ios::sync_with_stdio(false); 21 | cin.tie(0); 22 | cout.tie(0); 23 | int t = 1; 24 | // cin >> t; 25 | while (t--) 26 | solve(); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/M.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | string s1, s2; 8 | cin >> s1 >> s2; 9 | for (int i = 0; i < s1.length(); i++) 10 | { 11 | s1[i] = tolower(s1[i]); 12 | } 13 | for (int i = 0; i < s2.length(); i++) 14 | { 15 | s2[i] = tolower(s2[i]); 16 | } 17 | if (s1 < s2) 18 | { 19 | cout << "<" << endl; 20 | } 21 | else if (s1 > s2) 22 | { 23 | cout << ">" << endl; 24 | } 25 | else 26 | { 27 | cout << "=" << endl; 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /WHUT/2021/TeamExercise_01/D_TLE.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 200010 3 | 4 | using namespace std; 5 | 6 | long long a[SIZE]; 7 | 8 | int main(void) 9 | { 10 | int N; 11 | cin >> N; 12 | for (int i = 0; i < N; i++) 13 | { 14 | scanf("%lld", &a[i]); 15 | } 16 | long long ans = 0; 17 | for (int l = 0; l < N; l++) 18 | { 19 | long long minn = INT64_MAX; 20 | for (int r = l; r < N; r++) 21 | { 22 | minn = min(minn, a[r]); 23 | ans += minn; 24 | } 25 | } 26 | cout << ans << endl; 27 | return 0; 28 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_04/G.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int count, a, b, c; 7 | char temp; 8 | scanf("%d", &count); 9 | getchar(); 10 | while (count--) 11 | { 12 | a = b = c = 0; 13 | while ((temp = getchar()) != '\n') 14 | { 15 | if (temp == 'A') 16 | a++; 17 | else if (temp == 'B') 18 | b++; 19 | else if (temp == 'C') 20 | c++; 21 | } 22 | if (b == a + c) 23 | printf("YES\n"); 24 | else 25 | printf("NO\n"); 26 | } 27 | system("pause"); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT02/L1-8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int n; 8 | string c, s; 9 | cin >> n >> c; 10 | getchar(); 11 | getline(cin, s); 12 | if (n > s.size()) 13 | { 14 | for (int i = 0; i < n - s.size(); i++) 15 | cout << c; 16 | cout << s << endl; 17 | } 18 | else 19 | { 20 | cout << s.substr(s.size() - n) << endl; 21 | } 22 | } 23 | 24 | signed main() 25 | { 26 | solve(); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/246/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int x1, x2, x3, y1, y2, y3; 8 | cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; 9 | if (x1 == x2) 10 | cout << x3 << ' '; 11 | else if (x1 == x3) 12 | cout << x2 << ' '; 13 | else 14 | cout << x1 << ' '; 15 | if (y1 == y2) 16 | cout << y3 << endl; 17 | else if (y1 == y3) 18 | cout << y2 << endl; 19 | else 20 | cout << y1 << endl; 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#830 (Div. 2)/_B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 2e5 + 10; 6 | char s[MAXN] = {'0'}; 7 | 8 | void solve() 9 | { 10 | int n; 11 | cin >> n; 12 | cin >> s + 1; 13 | int cnt = 0; 14 | for (int i = 1; i <= n; i++) 15 | if (s[i] != s[i - 1]) 16 | cnt++; 17 | cout << max(0, cnt - 1) << endl; 18 | } 19 | 20 | int main() 21 | { 22 | int t; 23 | cin >> t; 24 | while (t--) 25 | solve(); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#909 (Div. 3)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | #define int long long 4 | 5 | using namespace std; 6 | 7 | void solve() 8 | { 9 | int n; 10 | cin >> n; 11 | if (n % 3 == 0) 12 | cout << "Second" << endl; 13 | else 14 | cout << "First" << endl; 15 | } 16 | 17 | signed main() 18 | { 19 | ios::sync_with_stdio(false); 20 | cin.tie(0); 21 | cout.tie(0); 22 | int t = 1; 23 | cin >> t; 24 | while (t--) 25 | solve(); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | bool light[5020]{}; 8 | int N, M; 9 | cin >> N >> M; 10 | for (int i = 1; i <= M; i++) 11 | { 12 | for (int j = i; j <= N; j += i) 13 | { 14 | light[j] = !light[j]; 15 | } 16 | } 17 | bool flag = false; 18 | for (int i = 1; i <= N; i++) 19 | { 20 | if (light[i]) 21 | { 22 | if (flag) 23 | { 24 | cout << ","; 25 | } 26 | cout << i; 27 | flag = true; 28 | } 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/L.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | string s; 8 | cin >> s; 9 | reverse(s.begin(), s.end()); 10 | for (int i = 0; i < s.length(); i++) 11 | { 12 | if (isupper(s[i])) 13 | { 14 | s[i] += 3; 15 | if (s[i] > 'Z') 16 | s[i] -= 26; 17 | s[i] = tolower(s[i]); 18 | } 19 | else 20 | { 21 | s[i] += 3; 22 | if (s[i] > 'z') 23 | s[i] -= 26; 24 | s[i] = toupper(s[i]); 25 | } 26 | } 27 | cout << s << endl; 28 | return 0; 29 | } -------------------------------------------------------------------------------- /WHUT/2022/Week03/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int m; 9 | cin >> m; 10 | while (m--) 11 | { 12 | int n; 13 | cin >> n; 14 | double ans = 1.0; 15 | for (int i = 2; i <= n; i++) 16 | { 17 | if (i % 2) 18 | ans += 1.0 / i; 19 | else 20 | ans -= 1.0 / i; 21 | } 22 | cout << fixed << setprecision(2) << ans << endl; 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /AcWing/900~999/913.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define int long long 3 | 4 | using namespace std; 5 | 6 | int n; 7 | priority_queue, greater> pque; 8 | 9 | signed main() 10 | { 11 | cin >> n; 12 | for (int i = 0; i < n; i++) 13 | { 14 | int t; 15 | cin >> t; 16 | pque.push(t); 17 | } 18 | int ans = 0; 19 | while (pque.size()) 20 | { 21 | ans += pque.top() * (pque.size() - 1); 22 | pque.pop(); 23 | } 24 | cout << ans << endl; 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Contest/Other/Robocom Province Contest/RC-u1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int N, M; 8 | cin >> N >> M; 9 | int ans = 0, coin = 0; 10 | for (int i = 0; i < N; i++) 11 | { 12 | int tmp; 13 | cin >> tmp; 14 | if (coin + tmp <= M) 15 | { 16 | coin += tmp; 17 | } 18 | else 19 | { 20 | coin = tmp; 21 | ans++; 22 | } 23 | } 24 | cout << ans << endl; 25 | return 0; 26 | } -------------------------------------------------------------------------------- /AcWing/800~899/866.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin >> n; 9 | while (n--) 10 | { 11 | int a; 12 | cin >> a; 13 | bool flag = true; 14 | if (a == 1) 15 | flag = false; 16 | for (int i = 2; i <= a / i; i++) 17 | if (!(a % i)) 18 | { 19 | flag = false; 20 | break; 21 | } 22 | cout << (flag ? "Yes" : "No") << endl; 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/250/_E_Kiri8128_hash.py: -------------------------------------------------------------------------------- 1 | def hs(): 2 | L = [0] 3 | S = set() 4 | A = [int(a) for a in input().split()] 5 | s = 0 6 | for i, a in enumerate(A): 7 | if a not in S: 8 | S.add(a) 9 | s = (s + a * (a + 1346) * (a + 9185)) % P 10 | L.append(s) 11 | return L 12 | 13 | 14 | P = 8128812800000059 15 | N = int(input()) 16 | X, Y = hs(), hs() 17 | Q = int(input()) 18 | for _ in range(Q): 19 | x, y = map(int, input().split()) 20 | print("Yes" if X[x] == Y[y] else "No") 21 | -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5723.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int L, sum = 0, count = 0; 6 | scanf("%d", &L); 7 | for (int i = 2;; i++) 8 | { 9 | int prime = 1; 10 | for (int j = 2; j * j < i + 1; j++) 11 | { 12 | if (i % j == 0) 13 | { 14 | prime = 0; 15 | } 16 | } 17 | if (prime == 1) 18 | { 19 | if (sum + i <= L) 20 | { 21 | sum += i; 22 | count++; 23 | printf("%d\n", i); 24 | } 25 | else 26 | { 27 | break; 28 | } 29 | } 30 | } 31 | printf("%d", count); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/Q.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int k; 8 | cin >> k; 9 | string s; 10 | cin >> s; 11 | int cnt = 1; 12 | bool flag = false; 13 | for (int i = 1; i < s.length(); i++) 14 | { 15 | if (s[i] == s[i - 1]) 16 | { 17 | cnt++; 18 | } 19 | else 20 | { 21 | if (cnt >= k) 22 | { 23 | flag = true; 24 | cout << s[i - 1]; 25 | break; 26 | } 27 | cnt = 1; 28 | } 29 | } 30 | if (!flag) 31 | cout << "No" << endl; 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/282/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | cin.tie(0); 10 | cout.tie(0); 11 | int N; 12 | cin >> N; 13 | string S; 14 | cin >> S; 15 | bool flag = false; 16 | for (int i = 0; i < N; i++) 17 | { 18 | if (S[i] == '"') 19 | flag = !flag; 20 | else if (S[i] == ',' && !flag) 21 | S[i] = '.'; 22 | } 23 | cout << S << endl; 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#855 (Div. 3)/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int n; 8 | string s; 9 | cin >> n >> s; 10 | int res = n - 1; 11 | for (int i = 1; i + 1 < n; i++) 12 | if (s[i - 1] == s[i + 1]) 13 | res--; 14 | cout << res << endl; 15 | } 16 | 17 | int main() 18 | { 19 | ios::sync_with_stdio(false); 20 | cin.tie(0); 21 | cout.tie(0); 22 | int t; 23 | cin >> t; 24 | while (t--) 25 | solve(); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Contest/Other/ChuanZhiBei 05/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector file; 8 | string line; 9 | while (getline(cin, line)) 10 | file.push_back(line); 11 | int line_cnt = file.size(); 12 | int line_cnt_width = 1, t = 10; 13 | while (line_cnt / t) 14 | { 15 | line_cnt_width++; 16 | t *= 10; 17 | } 18 | for (int i = 0; i < line_cnt; i++) 19 | cout << setw(line_cnt_width) << i + 1 << ' ' << file[i] << endl; 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Contest/Other/GPLT Campus Contest/7-6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | int n; 10 | cin >> n; 11 | int a[10010]; 12 | for (int i = 0; i < n; i++) 13 | cin >> a[i]; 14 | sort(a, a + n); 15 | int s; 16 | cin >> s; 17 | double ans = 0; 18 | while (s) 19 | { 20 | ans += 1.0 / a[0]; 21 | a[0]++; 22 | s--; 23 | sort(a, a + n); 24 | } 25 | printf("%.3lf", ans); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Contest/Other/WHU 2023/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | // #define int long long 4 | 5 | using namespace std; 6 | 7 | void solve() 8 | { 9 | int n; 10 | cin >> n; 11 | for (int i = 1; i <= n; i++) 12 | for (int j = 1; j <= n; j++) 13 | cout << (i - 1) * n + j << " \n"[j == n]; 14 | } 15 | 16 | signed main() 17 | { 18 | ios::sync_with_stdio(false); 19 | cin.tie(0); 20 | cout.tie(0); 21 | int t = 1; 22 | // cin >> t; 23 | while (t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1089.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int cash = 0, deposit = 0, budget[13]; 6 | for (int i = 1; i <= 12; i++) 7 | { 8 | scanf("%d", &budget[i]); 9 | } 10 | for (int i = 1; i <= 12; i++) 11 | { 12 | cash += 300; 13 | cash -= budget[i]; 14 | if (cash < 0) 15 | { 16 | printf("-%d", i); 17 | return 0; 18 | } 19 | if (cash / 100 > 0) 20 | { 21 | deposit += cash / 100 * 100; 22 | cash -= cash / 100 * 100; 23 | } 24 | } 25 | printf("%.0lf", 1.0 * cash + 1.2 * deposit); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1152.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin >> n; 9 | int nn = n; 10 | set s; 11 | int t; 12 | cin >> t; 13 | nn--; 14 | while (nn--) 15 | { 16 | int a; 17 | cin >> a; 18 | s.insert(abs(a - t)); 19 | t = a; 20 | } 21 | s.erase(0); 22 | if (s.size() == n - 1 && *s.rbegin() == n - 1) 23 | cout << "Jolly" << endl; 24 | else 25 | cout << "Not jolly" << endl; 26 | return 0; 27 | } -------------------------------------------------------------------------------- /WHUT/2021/TeamExercise_01/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define SIZE 80010 4 | 5 | using namespace std; 6 | 7 | int main(void) 8 | { 9 | int N; 10 | cin >> N; 11 | int height[SIZE]; 12 | for (int i = 0; i < N; i++) 13 | { 14 | scanf("%d", &height[i]); 15 | } 16 | stack q; 17 | long long ans = 0; 18 | for (int i = 0; i < N; i++) 19 | { 20 | while (!q.empty() && height[q.top()] <= height[i]) 21 | { 22 | q.pop(); 23 | } 24 | ans += q.size(); 25 | q.push(i); 26 | } 27 | cout << ans << endl; 28 | return 0; 29 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_09/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void hanoi(int, string, string, string); 6 | 7 | int main(void) 8 | { 9 | int n; 10 | string a, b, c; 11 | cin >> n >> a >> b >> c; 12 | hanoi(n, a, b, c); 13 | return 0; 14 | } 15 | 16 | void hanoi(int n, string a, string b, string c) 17 | { 18 | if (n == 1) 19 | { 20 | cout << n << ':' << a << "->" << c << endl; 21 | } 22 | else 23 | { 24 | hanoi(n - 1, a, c, b); 25 | cout << n << ':' << a << "->" << c << endl; 26 | hanoi(n - 1, b, a, c); 27 | } 28 | } -------------------------------------------------------------------------------- /WHUT/2022/Week02/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1e6 + 10; 6 | long long arr[MAXN]; 7 | void init() 8 | { 9 | arr[0] = 7 % 3; 10 | arr[1] = 11 % 3; 11 | for (int i = 2; i < MAXN; i++) 12 | arr[i] = (arr[i - 1] + arr[i - 2]) % 3; 13 | } 14 | 15 | int main() 16 | { 17 | init(); 18 | int n; 19 | while (cin >> n) 20 | { 21 | if (!arr[n]) 22 | cout << "yes" << endl; 23 | else 24 | cout << "no" << endl; 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/238/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | set cut; 8 | int N; 9 | cin >> N; 10 | int D = 0; 11 | cut.insert(D); 12 | for (int i = 0; i < N; i++) 13 | { 14 | int A; 15 | cin >> A; 16 | D += A; 17 | D %= 360; 18 | cut.insert(D); 19 | } 20 | int ans = 0; 21 | for (auto it = cut.begin(); next(it) != cut.end(); ++it) 22 | { 23 | ans = max(ans, *next(it) - *it); 24 | } 25 | ans = max(ans, 360 - *prev(cut.end())); 26 | cout << ans << endl; 27 | return 0; 28 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5736.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | bool prime[100000]; 6 | 7 | int main(void) 8 | { 9 | memset(prime, 1, sizeof prime); 10 | prime[0] = prime[1] = false; 11 | for (int i = 2; i < 100000; i++) 12 | { 13 | if (prime[i]) 14 | { 15 | for (int j = 2; j < 100000 / i; j++) 16 | { 17 | prime[i * j] = false; 18 | } 19 | } 20 | } 21 | int n; 22 | cin >> n; 23 | while (n--) 24 | { 25 | int tmp; 26 | cin >> tmp; 27 | if (prime[tmp]) 28 | cout << tmp << ' '; 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5738.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int n, m; 8 | double maxscore = 0; 9 | cin >> n >> m; 10 | while (n--) 11 | { 12 | int maxi = 0, mini = INT32_MAX; 13 | int sum = 0; 14 | for (int i = 0; i < m; i++) 15 | { 16 | int tmp; 17 | cin >> tmp; 18 | sum += tmp; 19 | maxi = max(maxi, tmp); 20 | mini = min(mini, tmp); 21 | } 22 | sum -= maxi + mini; 23 | maxscore = max(maxscore, 1.0 * sum / (m - 2)); 24 | } 25 | printf("%.2lf", maxscore); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Misc/01bag_Optimized.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int SIZE = 1010; 7 | int N, V; // N-物品数量 V-背包容积 8 | int v[SIZE], w[SIZE]; // v-体积 w-价值 9 | int dp[SIZE]; // 一维动态规划 10 | 11 | int main() 12 | { 13 | cin >> N >> V; 14 | for (int i = 1; i <= N; i++) 15 | cin >> v[i] >> w[i]; 16 | for (int i = 1; i <= N; i++) 17 | for (int j = V; j >= v[i]; j--) 18 | dp[j] = max(dp[j], dp[j - v[i]] + w[i]); 19 | cout << dp[V] << endl; 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Misc/Completebag.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int SIZE = 1010; 7 | int N, V; 8 | int v[SIZE], w[SIZE]; 9 | int dp[SIZE]; 10 | 11 | int main() 12 | { 13 | cin >> N >> V; 14 | for (int i = 1; i <= N; i++) 15 | cin >> v[i] >> w[i]; 16 | for (int i = 1; i <= N; i++) 17 | for (int j = V; j >= v[i]; j--) 18 | for (int k = 0; k * v[i] <= j; k++) 19 | dp[j] = max(dp[j], dp[j - k * v[i]] + k * w[i]); 20 | cout << dp[V] << endl; 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/237/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | vector mat[100000]; 6 | 7 | int main(void) 8 | { 9 | ios::sync_with_stdio(false); 10 | int H, W; 11 | cin >> H >> W; 12 | for (int i = 0; i < H; i++) 13 | { 14 | for (int j = 0; j < W; j++) 15 | { 16 | int tmp; 17 | cin >> tmp; 18 | mat[i].push_back(tmp); 19 | } 20 | } 21 | for (int i = 0; i < W; i++) 22 | { 23 | for (int j = 0; j < H; j++) 24 | { 25 | cout << mat[j][i] << ' '; 26 | } 27 | cout << endl; 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/276/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int N, M; 8 | cin >> N >> M; 9 | set ed[N + 1]; 10 | for (int i = 1; i <= M; i++) 11 | { 12 | int a, b; 13 | cin >> a >> b; 14 | ed[a].insert(b); 15 | ed[b].insert(a); 16 | } 17 | for (int i = 1; i <= N; i++) 18 | { 19 | cout << ed[i].size() << ' '; 20 | for (auto n : ed[i]) 21 | cout << n << ' '; 22 | cout << endl; 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#832 (Div. 2)/_A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int n; 8 | cin >> n; 9 | long long ans = 0; 10 | for (int i = 0; i < n; i++) 11 | { 12 | long long t; 13 | cin >> t; 14 | ans += t; 15 | } 16 | cout << abs(ans) << endl; 17 | } 18 | 19 | int main() 20 | { 21 | ios::sync_with_stdio(false); 22 | cin.tie(0); 23 | cout.tie(0); 24 | int t; 25 | cin >> t; 26 | while (t--) 27 | solve(); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#849 (Div. 4)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | const string cf = "codeforces"; 7 | 8 | void solve() 9 | { 10 | string c; 11 | cin >> c; 12 | if (cf.find(c) == cf.npos) 13 | cout << "No" << endl; 14 | else 15 | cout << "Yes" << endl; 16 | } 17 | 18 | int main() 19 | { 20 | ios_base::sync_with_stdio(false); 21 | cin.tie(0); 22 | cout.tie(0); 23 | int t; 24 | cin >> t; 25 | while (t--) 26 | solve(); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#867 (Div. 3)/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | typedef long long ll; 7 | 8 | void solve() 9 | { 10 | int n; 11 | cin >> n; 12 | ll base = 4, base_ans = 26; 13 | ll ans = base_ans + (base + 1 + n) * (n - base) + n - base; 14 | cout << ans << endl; 15 | } 16 | 17 | signed main() 18 | { 19 | ios::sync_with_stdio(false); 20 | cin.tie(0); 21 | cout.tie(0); 22 | int t; 23 | cin >> t; 24 | while (t--) 25 | solve(); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /WHUT/2022/Week03/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b; 8 | while (cin >> a >> b, a || b) 9 | { 10 | bool flag = false; 11 | a *= 100; 12 | for (int i = 0; i < 100; i++) 13 | { 14 | if (!((a + i) % b)) 15 | { 16 | if (flag) 17 | cout << ' '; 18 | printf("%02d", i); 19 | flag = true; 20 | } 21 | } 22 | cout << endl; 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/237/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | list lst; 6 | 7 | int main(void) 8 | { 9 | int N; 10 | string S; 11 | cin >> N >> S; 12 | lst.push_back(0); 13 | auto pos = lst.end(); 14 | for (int i = 1; i <= N; i++) 15 | { 16 | if (S[i - 1] == 'R') 17 | { 18 | lst.insert(pos, i); 19 | } 20 | else 21 | { 22 | --pos; 23 | lst.insert(pos, i); 24 | } 25 | } 26 | for (auto it = lst.begin(); it != lst.end(); ++it) 27 | { 28 | cout << *it << ' '; 29 | } 30 | cout << endl; 31 | return 0; 32 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/270/_D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1e5 + 10; 6 | int N, K, A[MAXN]; 7 | int dp[MAXN]; 8 | 9 | int main() 10 | { 11 | cin >> N >> K; 12 | for (int i = 0; i < K; i++) 13 | cin >> A[i]; 14 | for (int i = 0; i <= N; i++) 15 | { 16 | for (int j = 0; j < K; j++) 17 | { 18 | if (i < A[j]) 19 | break; 20 | dp[i] = max(dp[i], i - dp[i - A[j]]); 21 | } 22 | } 23 | cout << dp[N] << endl; 24 | return 0; 25 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_01/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int M, N, X, m = 0; 8 | cin >> M >> N >> X; 9 | while (1) 10 | { 11 | if (X >= ceil(1.0 * M / N)) 12 | { 13 | X -= ceil(1.0 * M / N); 14 | m = M; 15 | } 16 | else 17 | { 18 | break; 19 | } 20 | int cnt = 0; 21 | while (1) 22 | { 23 | m -= N; 24 | if (m >= 0) 25 | { 26 | cnt++; 27 | } 28 | else 29 | { 30 | break; 31 | } 32 | } 33 | N += cnt; 34 | } 35 | cout << N << endl; 36 | return 0; 37 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_03/O.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int length, temp; 7 | scanf("%d", &length); 8 | int num[99]; 9 | for (int i = 0; i < 99; i++) 10 | num[i] = 0; 11 | for (int i = 0; i < length; i++) 12 | { 13 | scanf("%d", &temp); 14 | num[temp + 49]++; 15 | } 16 | int x = 0; 17 | for (int i = 0; i < 99; i++) 18 | { 19 | if (num[i] > length / 2) 20 | { 21 | printf("%d", i - 49); 22 | x = 1; 23 | } 24 | } 25 | if (x == 0) 26 | { 27 | printf("no"); 28 | } 29 | system("pause"); 30 | return 0; 31 | } -------------------------------------------------------------------------------- /AcWing/800~899/877.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int exgcd(int a, int b, int &x, int &y) 6 | { 7 | if (!b) 8 | { 9 | x = 1; 10 | y = 0; 11 | return a; 12 | } 13 | int d = exgcd(b, a % b, y, x); 14 | y -= a / b * x; 15 | return d; 16 | } 17 | 18 | int main() 19 | { 20 | int n; 21 | cin >> n; 22 | while (n--) 23 | { 24 | int a, b, x, y; 25 | cin >> a >> b; 26 | exgcd(a, b, x, y); 27 | cout << x << ' ' << y << endl; 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/253/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int H, W; 8 | cin >> H >> W; 9 | vector> piece; 10 | for (int i = 0; i < H; i++) 11 | { 12 | string line; 13 | cin >> line; 14 | for (int j = 0; j < W; j++) 15 | { 16 | if (line[j] == 'o') 17 | piece.push_back({i, j}); 18 | } 19 | } 20 | cout << abs(piece[0].first - piece[1].first) + abs(piece[0].second - piece[1].second) << endl; 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/269/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | vector> vec; 8 | for (int i = 0; i < 10; i++) 9 | { 10 | string s; 11 | cin >> s; 12 | for (int j = 0; j < 10; j++) 13 | { 14 | if (s[j] == '#') 15 | vec.push_back({i, j}); 16 | } 17 | } 18 | cout << vec.front().first + 1 << ' ' << vec.back().first + 1 << endl 19 | << vec.front().second + 1 << ' ' << vec.back().second + 1 << endl; 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/270/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int X, Y, Z; 6 | 7 | int main() 8 | { 9 | cin >> X >> Y >> Z; 10 | if ((0 < Y && Y < X) || (X < Y && Y < 0)) 11 | { 12 | if ((0 < Y && Y < Z) || (Z < Y && Y < 0)) 13 | cout << -1 << endl; 14 | else if (X * Z < 0) 15 | cout << 2 * abs(Z) + abs(X) << endl; 16 | else if (X * Z > 0) 17 | cout << abs(X) << endl; 18 | } 19 | else 20 | { 21 | cout << abs(X) << endl; 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#874 (Div. 3)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int n; 9 | cin >> n; 10 | string s; 11 | cin >> s; 12 | set st; 13 | for (int i = 0; i < s.size() - 1; i++) 14 | st.insert(s.substr(i, 2)); 15 | cout << st.size() << endl; 16 | } 17 | 18 | signed main() 19 | { 20 | ios::sync_with_stdio(false); 21 | cin.tie(0); 22 | cout.tie(0); 23 | int t; 24 | cin >> t; 25 | while (t--) 26 | solve(); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1102.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | // freopen("P1102_3.in", "r", stdin); 8 | int N, C; 9 | int num[200020]; 10 | cin >> N >> C; 11 | for (int i = 0; i < N; i++) 12 | { 13 | scanf("%d", &num[i]); 14 | } 15 | sort(num, num + N); 16 | long long count = 0; 17 | for (int i = 0; i < N; i++) 18 | { 19 | int r1 = lower_bound(num, num + N, num[i] - C) - num; 20 | int r2 = upper_bound(num, num + N, num[i] - C) - num; 21 | count += (r2 - r1); 22 | } 23 | cout << count << endl; 24 | return 0; 25 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT03/L1-3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | double a; 9 | int b; 10 | double c; 11 | cin >> a >> b >> c; 12 | double lim = a * (b == 0 ? 2.455 : 1.26); 13 | cout << fixed << setprecision(2) << lim << ' '; 14 | if (lim > c) 15 | cout << "T_T" << endl; 16 | else 17 | cout << "^_^" << endl; 18 | } 19 | 20 | signed main() 21 | { 22 | ios::sync_with_stdio(false); 23 | cin.tie(0); 24 | cout.tie(0); 25 | solve(); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT03/L1-4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int n; 9 | cin >> n; 10 | double ans = 0.0; 11 | for (int i = 0; i < n; i++) 12 | { 13 | double t; 14 | cin >> t; 15 | ans += 1.0 / t; 16 | } 17 | ans /= n; 18 | ans = 1.0 / ans; 19 | cout << fixed << setprecision(2) << ans << endl; 20 | } 21 | 22 | signed main() 23 | { 24 | ios::sync_with_stdio(false); 25 | cin.tie(0); 26 | cout.tie(0); 27 | solve(); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /WHUT/2023/Summer01/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int x, n, m; 9 | cin >> x >> n >> m; 10 | while (x > 20 && n--) 11 | { 12 | x = x / 2 + 10; 13 | } 14 | if (x > m * 10) 15 | cout << "NO" << endl; 16 | else 17 | cout << "YES" << endl; 18 | } 19 | 20 | signed main() 21 | { 22 | ios::sync_with_stdio(false); 23 | cin.tie(0); 24 | cout.tie(0); 25 | int t; 26 | cin >> t; 27 | while (t--) 28 | solve(); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/284/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int N; 9 | cin >> N; 10 | int ans = 0; 11 | for (int i = 0; i < N; i++) 12 | { 13 | int t; 14 | cin >> t; 15 | if (t & 1) 16 | ans++; 17 | } 18 | cout << ans << endl; 19 | } 20 | 21 | int main() 22 | { 23 | ios_base::sync_with_stdio(false); 24 | cin.tie(0); 25 | cout.tie(0); 26 | int t; 27 | cin >> t; 28 | while (t--) 29 | solve(); 30 | return 0; 31 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#871 (Div. 4)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | const string cf = "codeforces"; 7 | 8 | void solve() 9 | { 10 | string s; 11 | cin >> s; 12 | int n = 0; 13 | for (int i = 0; i < s.size(); i++) 14 | if (s[i] != cf[i]) 15 | n++; 16 | cout << n << endl; 17 | } 18 | 19 | signed main() 20 | { 21 | ios::sync_with_stdio(false); 22 | cin.tie(0); 23 | cout.tie(0); 24 | int t; 25 | cin >> t; 26 | while (t--) 27 | solve(); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#875 (Div. 2)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int n; 9 | cin >> n; 10 | int base = n + 1; 11 | for (int i = 0; i < n; i++) 12 | { 13 | int t; 14 | cin >> t; 15 | cout << base - t << ' '; 16 | } 17 | cout << endl; 18 | } 19 | 20 | signed main() 21 | { 22 | ios::sync_with_stdio(false); 23 | cin.tie(0); 24 | cout.tie(0); 25 | int t; 26 | cin >> t; 27 | while (t--) 28 | solve(); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /LuoGu/3000~3999/P3817.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define int long long 3 | 4 | using namespace std; 5 | 6 | const int MAXN = 1e5 + 10; 7 | int n, x; 8 | int a[MAXN]; 9 | int ans = 0; 10 | 11 | signed main() 12 | { 13 | cin >> n >> x; 14 | for (int i = 1; i <= n; i++) 15 | cin >> a[i]; 16 | for (int i = 1; i <= n; i++) 17 | { 18 | if (a[i - 1] + a[i] >= x) 19 | { 20 | int t = a[i - 1] + a[i] - x; 21 | ans += t; 22 | a[i] -= t; 23 | } 24 | } 25 | cout << ans << endl; 26 | return 0; 27 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_08/test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | unsigned long long n, i; 6 | cin >> n; 7 | unsigned long long int sum = 0; 8 | sum = n * (n + 1) / 2; //等差数列求和 9 | if (n < 100000000) 10 | { 11 | for (i = sum / 2; sum % i != 0 && i >= sqrt(sum); i--) 12 | ; //通过求最小因数计算最大因数 节省时间 13 | cout << i; 14 | } 15 | else 16 | { //n超过1亿时从2开始可节约大量时间 17 | for (i = 2; i < sqrt(n); i++) 18 | { 19 | if (sum % i == 0) 20 | { 21 | sum /= i; 22 | break; 23 | } 24 | } 25 | cout << sum; 26 | } 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /WHUT/2022/Week03/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 55; 6 | int t, n; 7 | int a[MAXN]; 8 | set s; 9 | 10 | int main() 11 | { 12 | cin >> t; 13 | while (t--) 14 | { 15 | s.clear(); 16 | cin >> n; 17 | for (int i = 0; i < n; i++) 18 | { 19 | cin >> a[i]; 20 | s.insert(a[i]); 21 | } 22 | if ((n - s.size()) % 2) 23 | cout << s.size() - 1 << endl; 24 | else 25 | cout << s.size() << endl; 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /AcWing/900~999/905.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int N; 8 | cin >> N; 9 | vector> area; 10 | while (N--) 11 | { 12 | int a, b; 13 | cin >> a >> b; 14 | area.push_back({b, a}); 15 | } 16 | sort(area.begin(), area.end()); 17 | int ans = 0, r = INT32_MIN; 18 | for (auto p : area) 19 | { 20 | if (p.second > r) 21 | { 22 | ans++; 23 | r = p.first; 24 | } 25 | } 26 | cout << ans << endl; 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/283/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | long long fastpow(long long a, long long b) 7 | { 8 | long long ans = 1; 9 | while (b) 10 | { 11 | if (b % 2 == 1) 12 | ans = ans * a; 13 | a = a * a; 14 | b >>= 1; 15 | } 16 | return ans; 17 | } 18 | 19 | int main() 20 | { 21 | ios_base::sync_with_stdio(false); 22 | cin.tie(0); 23 | cout.tie(0); 24 | long long A, B; 25 | cin >> A >> B; 26 | cout << fastpow(A, B) << endl; 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/Global Round #23/_C_better.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1e5 + 10; 6 | int ans[MAXN]; 7 | 8 | void solve() 9 | { 10 | int n; 11 | cin >> n; 12 | for (int i = 1; i <= n; i++) 13 | { 14 | int t; 15 | cin >> t; 16 | ans[t] = i % n + 1; 17 | } 18 | for (int i = 1; i <= n; i++) 19 | cout << ans[i] << ' '; 20 | cout << endl; 21 | } 22 | 23 | int main() 24 | { 25 | int t; 26 | cin >> t; 27 | while (t--) 28 | solve(); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Contest/Other/HRBUST 2021/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int x; 8 | cin >> x; 9 | if (x == 1) 10 | cout << "You were studying Higher mathematics!" << endl; 11 | else if (x == 2) 12 | cout << "You were studying Linear algebra!" << endl; 13 | else if (x == 3) 14 | cout << "You were studying Principle of computer composition!" << endl; 15 | else if (x == 4) 16 | cout << "You were studying Database system concept!" << endl; 17 | else 18 | cout << "You were playing games!" << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5735.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | double length(double x1, double y1, double x2, double y2) 6 | { 7 | return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)); 8 | } 9 | 10 | int main(void) 11 | { 12 | double x1, x2, x3, y1, y2, y3; 13 | cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; 14 | double a, b, c, p; 15 | a = length(x1, y1, x2, y2); 16 | b = length(x1, y1, x3, y3); 17 | c = length(x2, y2, x3, y3); 18 | // p = (a + b + c) / 2; 19 | // double ans = sqrt(p * (p - a) * (p - b) * (p - c)); 20 | printf("%.2lf", a + b + c); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Misc/Multiplebag.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int SIZE = 1010; 7 | int N, V; 8 | int v[SIZE], w[SIZE], s[SIZE]; 9 | int dp[SIZE]; 10 | 11 | int main() 12 | { 13 | cin >> N >> V; 14 | for (int i = 1; i <= N; i++) 15 | cin >> v[i] >> w[i] >> s[i]; 16 | for (int i = 1; i <= N; i++) 17 | for (int j = V; j >= v[i]; j--) 18 | for (int k = 0; k * v[i] <= j && k <= s[i]; k++) 19 | dp[j] = max(dp[j], dp[j - k * v[i]] + k * w[i]); 20 | cout << dp[V] << endl; 21 | return 0; 22 | } -------------------------------------------------------------------------------- /WHUT/2022/Week06/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 110; 6 | int n, m; 7 | multiset s; 8 | 9 | int main() 10 | { 11 | cin >> n >> m; 12 | int mx = 0; 13 | for (int i = 0; i < n; i++) 14 | { 15 | int t; 16 | cin >> t; 17 | mx = max(mx, t); 18 | s.insert(t); 19 | } 20 | mx += m; 21 | while (m--) 22 | { 23 | int t = *s.begin(); 24 | s.extract(t); 25 | s.insert(t + 1); 26 | } 27 | cout << *s.rbegin() << ' ' << mx << endl; 28 | return 0; 29 | } -------------------------------------------------------------------------------- /AcWing/800~899/896.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1e5 + 10; 6 | int N, num[MAXN]; 7 | vector vec; 8 | 9 | int main() 10 | { 11 | cin >> N; 12 | for (int i = 1; i <= N; i++) 13 | cin >> num[i]; 14 | vec.push_back(num[1]); 15 | for (int i = 2; i <= N; i++) 16 | { 17 | if (num[i] > vec.back()) 18 | vec.push_back(num[i]); 19 | else 20 | vec[lower_bound(vec.begin(), vec.end(), num[i]) - vec.begin()] = num[i]; 21 | } 22 | cout << vec.size() << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/268/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 2e5 + 10; 6 | int N, p[MAXN]; 7 | 8 | int main() 9 | { 10 | cin >> N; 11 | for (int i = 0; i < N; i++) 12 | cin >> p[i]; 13 | map mp; 14 | for (int i = 0; i < N; i++) 15 | { 16 | mp[(p[i] - i - 1 + N) % N]++; 17 | mp[(p[i] - i + N) % N]++; 18 | mp[(p[i] - i + 1 + N) % N]++; 19 | } 20 | int mx = 0; 21 | for (auto par : mp) 22 | mx = max(mx, par.second); 23 | cout << mx << endl; 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/Global Round #23/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int n, k; 8 | cin >> n >> k; 9 | bool have_one = false; 10 | for (int i = 1; i <= n; i++) 11 | { 12 | int t; 13 | cin >> t; 14 | if (t) 15 | have_one = true; 16 | } 17 | if (have_one) 18 | cout << "YES" << endl; 19 | else 20 | cout << "NO" << endl; 21 | } 22 | 23 | int main() 24 | { 25 | int t; 26 | cin >> t; 27 | while (t--) 28 | solve(); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#835 (Div. 4)/_C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int n; 8 | cin >> n; 9 | vector s(n); 10 | for (int i = 0; i < n; i++) 11 | cin >> s[i]; 12 | vector ss(s); 13 | sort(ss.begin(), ss.end(), greater()); 14 | for (int i = 0; i < n; i++) 15 | cout << (s[i] == ss[0] ? ss[0] - ss[1] : s[i] - ss[0]) << ' '; 16 | cout << endl; 17 | } 18 | 19 | int main() 20 | { 21 | int t; 22 | cin >> t; 23 | while (t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_02/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int abgk[10010][4]; 6 | 7 | int main(void) 8 | { 9 | int n; 10 | cin >> n; 11 | for (int i = 0; i < n; i++) 12 | { 13 | scanf("%d%d%d%d", &abgk[i][0], &abgk[i][1], &abgk[i][2], &abgk[i][3]); 14 | } 15 | int x, y; 16 | cin >> x >> y; 17 | int ans = 0; 18 | for (int i = 0; i < n; i++) 19 | { 20 | if (x >= abgk[i][0] && x <= abgk[i][0] + abgk[i][2] && y >= abgk[i][1] && y <= abgk[i][1] + abgk[i][3]) 21 | { 22 | ans = i + 1; 23 | } 24 | } 25 | cout << ans << endl; 26 | return 0; 27 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_02/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define LENGTH 10010 3 | 4 | using namespace std; 5 | 6 | int main(void) 7 | { 8 | int l, m, u, v; 9 | bool tree[LENGTH] = {false}; 10 | cin >> l >> m; 11 | for (int i = 0; i < l + 1; i++) 12 | { 13 | tree[i] = true; 14 | } 15 | while (m--) 16 | { 17 | cin >> u >> v; 18 | for (int i = u; i <= v; i++) 19 | { 20 | tree[i] = false; 21 | } 22 | } 23 | int count = 0; 24 | for (int i = 0; i < LENGTH; i++) 25 | { 26 | if (tree[i]) 27 | { 28 | count++; 29 | } 30 | } 31 | cout << count << endl; 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#829 (Div. 2)/_D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, x; 8 | cin >> n >> x; 9 | vector a(x + 10); 10 | for (int i = 1; i <= n; i++) 11 | { 12 | int t; 13 | cin >> t; 14 | a[t]++; 15 | } 16 | for (int i = 1; i < x; i++) 17 | { 18 | if (a[i] % (i + 1)) 19 | { 20 | cout << "No" << endl; 21 | return 0; 22 | } 23 | a[i + 1] += a[i] / (i + 1); 24 | } 25 | cout << "Yes" << endl; 26 | return 0; 27 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1614.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define LENGTH 3010 3 | #define min(a, b) (a < b) ? a : b 4 | 5 | using namespace std; 6 | 7 | int main(void) 8 | { 9 | int n, m, a[LENGTH], ans = INT32_MAX; 10 | cin >> n >> m; 11 | for (int i = 0; i < n; i++) 12 | { 13 | cin >> a[i]; 14 | } 15 | for (int i = 0; i <= n - m; i++) 16 | { 17 | int sum = 0; 18 | for (int j = i; j < i + m; j++) 19 | { 20 | sum += a[j]; 21 | } 22 | ans = min(ans, sum); 23 | } 24 | cout << ans << endl; 25 | return 0; 26 | } -------------------------------------------------------------------------------- /WHUT/2021/TeamExercise_08/C_useDP.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int n, t; 6 | int num[25]; 7 | int dp[25][1010]; 8 | 9 | int main() 10 | { 11 | scanf("%d%d", &n, &t); 12 | for (int i = 0; i < n; i++) 13 | scanf("%d", &num[i]); 14 | dp[0][0] = 1; 15 | for (int i = 0; i <= n; i++) 16 | { 17 | for (int j = 0; j <= 1000; j++) 18 | { 19 | dp[i + 1][j] += dp[i][j]; 20 | if (j + num[i] <= 1000) 21 | dp[i + 1][j + num[i]] += dp[i][j]; 22 | } 23 | } 24 | printf("%d\n", dp[n][t]); 25 | } -------------------------------------------------------------------------------- /WHUT/2022/Homework/Y.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | typedef long long ll; 7 | 8 | void solve() 9 | { 10 | ll n, m; 11 | cin >> n >> m; 12 | ll ans = 0; 13 | for (int i = 0; i < min(n, m); i++) 14 | { 15 | ll a = n - i, b = m - i; 16 | ans += a * b; 17 | } 18 | cout << ans << endl; 19 | } 20 | 21 | int main() 22 | { 23 | ios_base::sync_with_stdio(false); 24 | cin.tie(0); 25 | cout.tie(0); 26 | int t; 27 | cin >> t; 28 | while (t--) 29 | solve(); 30 | return 0; 31 | } -------------------------------------------------------------------------------- /AcWing/800~899/897.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1010; 6 | int N, M; 7 | char A[MAXN], B[MAXN]; 8 | int dp[MAXN][MAXN]; 9 | 10 | int main() 11 | { 12 | cin >> N >> M; 13 | cin >> A + 1 >> B + 1; 14 | for (int i = 1; i <= N; i++) 15 | { 16 | for (int j = 1; j <= M; j++) 17 | { 18 | dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); 19 | if (A[i] == B[j]) 20 | dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1); 21 | } 22 | } 23 | cout << dp[N][M] << endl; 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/271/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const char dig[16] = {'0', '1', '2', '3', 6 | '4', '5', '6', '7', 7 | '8', '9', 'A', 'B', 8 | 'C', 'D', 'E', 'F'}; 9 | 10 | int main() 11 | { 12 | int num; 13 | cin >> num; 14 | vector ans; 15 | while (num) 16 | { 17 | ans.push_back(dig[num % 16]); 18 | num /= 16; 19 | } 20 | while (ans.size() < 2) 21 | ans.push_back('0'); 22 | cout << ans[1] << ans[0] << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#847 (Div. 3)/_A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | string ans = "314159265358979323846264338327"; 7 | 8 | int solve() 9 | { 10 | string s; 11 | cin >> s; 12 | for (int i = 0; i < s.size(); i++) 13 | if (ans[i] != s[i]) 14 | return i; 15 | return s.size(); 16 | } 17 | 18 | int main() 19 | { 20 | ios_base::sync_with_stdio(false); 21 | cin.tie(0); 22 | cout.tie(0); 23 | int t; 24 | cin >> t; 25 | while (t--) 26 | cout << solve() << endl; 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#849 (Div. 4)/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int n; 9 | cin >> n; 10 | string s; 11 | cin >> s; 12 | int l = 0, r = n - 1; 13 | for (; l < r; l++, r--) 14 | if (s[l] + s[r] - 2 * '0' != 1) 15 | break; 16 | cout << r - l + 1 << endl; 17 | } 18 | 19 | int main() 20 | { 21 | ios_base::sync_with_stdio(false); 22 | cin.tie(0); 23 | cout.tie(0); 24 | int t; 25 | cin >> t; 26 | while (t--) 27 | solve(); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Contest/Other/Nowcoder Beginner Contest/43/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 500100 3 | 4 | using namespace std; 5 | 6 | int main(void) 7 | { 8 | int n; 9 | cin >> n; 10 | int odd = 0; 11 | int pos[SIZE]; 12 | int p = 0; 13 | for (int i = 1; i <= n; i++) 14 | { 15 | int t; 16 | scanf("%d", &t); 17 | if (t % 2) 18 | { 19 | odd++; 20 | pos[p++] = i; 21 | } 22 | } 23 | long long ans = 0; 24 | int l = 1; 25 | for (int i = 0; i < p; i++) 26 | { 27 | ans += (pos[i] - l + 1) * (n - pos[i] + 1); 28 | l = pos[i] + 1; 29 | } 30 | cout << ans << endl; 31 | return 0; 32 | } -------------------------------------------------------------------------------- /AcWing/700~799/789.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 1e5 + 10; 6 | int n, q; 7 | int arr[MAXN]; 8 | 9 | int main() 10 | { 11 | cin >> n >> q; 12 | for (int i = 0; i < n; i++) 13 | cin >> arr[i]; 14 | while (q--) 15 | { 16 | int k; 17 | cin >> k; 18 | int x = lower_bound(arr, arr + n, k) - arr, y = upper_bound(arr, arr + n, k) - arr; 19 | if (x == n || arr[x] != k) 20 | cout << "-1 -1" << endl; 21 | else 22 | cout << x << ' ' << y - 1 << endl; 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /AcWing/800~899/875.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | long long fast_pow(long long a, long long b, long long p) 6 | { 7 | a %= p; 8 | long long ans = 1; 9 | while (b) 10 | { 11 | if (b % 2) 12 | ans = ans * a % p; 13 | a = a * a % p; 14 | b /= 2; 15 | } 16 | return ans; 17 | } 18 | 19 | int main() 20 | { 21 | long long n; 22 | cin >> n; 23 | while (n--) 24 | { 25 | long long a, b, p; 26 | cin >> a >> b >> p; 27 | cout << fast_pow(a, b, p) << endl; 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/246/_D_PublicSolution.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | long long f(long long a, long long b) 6 | { 7 | return (a * a * a + a * a * b + a * b * b + b * b * b); 8 | } 9 | 10 | int main() 11 | { 12 | long long n; 13 | cin >> n; 14 | long long x = 8e18; 15 | long long j = 1000000; 16 | for (long long i = 0; i <= 1000000; i++) 17 | { 18 | while (f(i, j) >= n && j >= 0) 19 | { 20 | x = min(x, f(i, j)); 21 | j--; 22 | } 23 | } 24 | cout << x << '\n'; 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#844 (Div. 1 + Div. 2)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int w, d, h; 9 | cin >> w >> d >> h; 10 | int a, b, f, g; 11 | cin >> a >> b >> f >> g; 12 | int ans = h + abs(a - f) + abs(b - g) + 2 * min({a, w - a, b, d - b, f, w - f, g, d - g}); 13 | cout << ans << endl; 14 | } 15 | 16 | int main() 17 | { 18 | ios_base::sync_with_stdio(false); 19 | cin.tie(0); 20 | cout.tie(0); 21 | int t; 22 | cin >> t; 23 | while (t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#883 (Div. 3)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int n; 9 | cin >> n; 10 | int ans = 0; 11 | for (int i = 0; i < n; i++) 12 | { 13 | int a, b; 14 | cin >> a >> b; 15 | if (a - b > 0) 16 | ans++; 17 | } 18 | cout << ans << endl; 19 | } 20 | 21 | signed main() 22 | { 23 | ios::sync_with_stdio(false); 24 | cin.tie(0); 25 | cout.tie(0); 26 | int t; 27 | cin >> t; 28 | while (t--) 29 | solve(); 30 | return 0; 31 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1090.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin >> n; 9 | priority_queue, greater> pque; 10 | while (n--) 11 | { 12 | int t; 13 | cin >> t; 14 | pque.push(t); 15 | } 16 | int ans = 0; 17 | while (pque.size() >= 2) 18 | { 19 | int a = pque.top(); 20 | pque.pop(); 21 | int b = pque.top(); 22 | pque.pop(); 23 | ans += a + b; 24 | pque.push(a + b); 25 | } 26 | cout << ans << endl; 27 | return 0; 28 | } -------------------------------------------------------------------------------- /WHUT/2021/CampusExercise_02/M.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | pair ball[1000010]; 6 | 7 | bool cmp(pair a, pair b) 8 | { 9 | return a.first < b.first; 10 | } 11 | 12 | int main(void) 13 | { 14 | ios::sync_with_stdio(false); 15 | int N, K; 16 | cin >> N >> K; 17 | 18 | int k = 0; 19 | for (int i = 1; i <= K; i++) 20 | { 21 | int T; 22 | cin >> T; 23 | for (int j = 0; j < T; j++) 24 | { 25 | int pos = 0; 26 | cin >> pos; 27 | ball[k++] = {pos, i}; 28 | } 29 | } 30 | sort(ball, ball + k, cmp); 31 | 32 | return 0; 33 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_05/A.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | int input, sumall = 0, sumleft = 0, sum = 0; 7 | scanf("%d", &input); 8 | int left = 0, right = 0; 9 | while (right < input) 10 | { 11 | sum = sumall - sumleft; 12 | if (sum < input) 13 | { 14 | right++; 15 | sumall += right; 16 | } 17 | else if (sum > input) 18 | { 19 | left++; 20 | sumleft += left; 21 | } 22 | else if (sum == input) 23 | { 24 | printf("%d %d\n", left + 1, right); 25 | right++; 26 | sumall += right; 27 | } 28 | } 29 | system("pause"); 30 | return 0; 31 | } -------------------------------------------------------------------------------- /WHUT/2022/Mystery/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int t; 8 | cin >> t; 9 | while (t--) 10 | { 11 | int n; 12 | cin >> n; 13 | string a, b; 14 | cin >> a >> b; 15 | for (int i = 0; i < n; i++) 16 | { 17 | if (a[i] == 'B') 18 | a[i] = 'G'; 19 | if (b[i] == 'B') 20 | b[i] = 'G'; 21 | } 22 | if (a == b) 23 | cout << "YES" << endl; 24 | else 25 | cout << "NO" << endl; 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /AcWing/800~899/873.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin >> n; 9 | while (n--) 10 | { 11 | int a; 12 | cin >> a; 13 | int ans = a; 14 | for (int i = 2; i <= a / i; i++) 15 | { 16 | if (!(a % i)) 17 | { 18 | ans = ans / i * (i - 1); 19 | while (!(a % i)) 20 | a /= i; 21 | } 22 | } 23 | if (a > 1) 24 | ans = ans / a * (a - 1); 25 | cout << ans << endl; 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /LuoGu/2000~2999/P2676.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 2e4 + 10; 6 | int N, B; 7 | int H[MAXN]; 8 | 9 | signed main() 10 | { 11 | cin >> N >> B; 12 | for (int i = 0; i < N; i++) 13 | cin >> H[i]; 14 | sort(H, H + N); 15 | int ans = 1; 16 | while (true) 17 | { 18 | if (B > H[N - ans]) 19 | { 20 | B -= H[N - ans]; 21 | ans++; 22 | } 23 | else 24 | { 25 | ans++; 26 | break; 27 | } 28 | } 29 | cout << ans - 1 << endl; 30 | return 0; 31 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5788.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 3000010 3 | 4 | using namespace std; 5 | 6 | int num[SIZE]; 7 | long long ans[SIZE]; 8 | 9 | int main(void) 10 | { 11 | int n; 12 | cin >> n; 13 | for (int i = 0; i < n; i++) 14 | { 15 | scanf("%d", &num[i]); 16 | } 17 | stack st; 18 | for (int i = n - 1; i >= 0; i--) 19 | { 20 | while (!st.empty() && num[st.top()] <= num[i]) 21 | { 22 | st.pop(); 23 | } 24 | ans[i] = st.empty() ? 0 : (st.top() + 1); 25 | st.push(i); 26 | } 27 | for (int i = 0; i < n; i++) 28 | { 29 | printf("%lld ", ans[i]); 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_03/J.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int N, M; 8 | scanf("%d%d", &N, &M); 9 | bool a[N]; 10 | for (int i = 0; i < N; i++) 11 | a[i] = 1; 12 | for (int i = 0; i < M; i++) 13 | { 14 | for (int j = i + 1; j < N + 1; j += i + 1) 15 | { 16 | if (a[j - 1]) 17 | a[j - 1] = false; 18 | else 19 | a[j - 1] = true; 20 | } 21 | } 22 | for (int i = 0; i < N; i++) 23 | { 24 | if (!a[i]) 25 | { 26 | if (i != 0) 27 | printf(","); 28 | printf("%d", i + 1); 29 | } 30 | } 31 | system("pause"); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_04/E.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int count, m, n, max, ans, _m, a; 8 | scanf("%d", &count); 9 | while (count--) 10 | { 11 | ans = 0; 12 | scanf("%d%d", &n, &m); 13 | _m = (m >= 30) ? 30 : m; 14 | for (int j = _m; j >= 0; j--) 15 | { 16 | if (pow(2, j) <= n) 17 | { 18 | max = j; 19 | break; 20 | } 21 | } 22 | while (n > 0) 23 | { 24 | a = n / pow(2, max); 25 | ans += a; 26 | n -= a * pow(2, max); 27 | max--; 28 | } 29 | printf("%d\n", ans); 30 | } 31 | system("pause"); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /WHUT/2022/Week04/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int T; 8 | cin >> T; 9 | while (T--) 10 | { 11 | int n, m; 12 | cin >> n >> m; 13 | int ans = 0; 14 | if (m > 30) 15 | m = 30; 16 | for (int i = m; i >= 0; i--) 17 | { 18 | int p = 1 << i; 19 | if (n >= p) 20 | { 21 | int t = n / p; 22 | n -= t * p; 23 | ans += t; 24 | } 25 | } 26 | cout << ans << endl; 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/Global Round #24/_B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int n; 9 | cin >> n; 10 | int tmp = 0; 11 | vector a(n); 12 | for (int i = 0; i < n; i++) 13 | { 14 | cin >> a[i]; 15 | tmp = __gcd(a[i], tmp); 16 | } 17 | cout << a.back() / tmp + (!a.front()) << endl; 18 | } 19 | 20 | int main() 21 | { 22 | ios_base::sync_with_stdio(false); 23 | cin.tie(0); 24 | cout.tie(0); 25 | int t; 26 | cin >> t; 27 | while (t--) 28 | solve(); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#825 (Div. 2)/_C1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 2e5 + 10; 6 | int t, n; 7 | int a[MAXN]; 8 | int dp[MAXN]; 9 | 10 | int main() 11 | { 12 | cin >> t; 13 | while (t--) 14 | { 15 | int n; 16 | cin >> n; 17 | for (int i = 1; i <= n; i++) 18 | cin >> a[i]; 19 | long long ans = 0; 20 | for (int i = 1; i <= n; i++) 21 | { 22 | dp[i] = min(dp[i - 1] + 1, a[i]); 23 | ans += dp[i]; 24 | } 25 | cout << ans << endl; 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1216.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int SIZE = 1010; 6 | int tri[SIZE][SIZE]; 7 | 8 | int main() 9 | { 10 | int r; 11 | cin >> r; 12 | for (int i = 0; i < r; i++) 13 | { 14 | for (int j = 0; j < i + 1; j++) 15 | { 16 | cin >> tri[i][j]; 17 | } 18 | } 19 | for (int i = r - 1; i >= 0; i--) 20 | { 21 | for (int j = 0; j < i + 1; j++) 22 | { 23 | tri[i][j] += max(tri[i + 1][j], tri[i + 1][j + 1]); 24 | } 25 | } 26 | cout << tri[0][0] << endl; 27 | return 0; 28 | } -------------------------------------------------------------------------------- /LuoGu/5000~5999/P5725.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int scale, num = 1; 6 | scanf("%d", &scale); 7 | for (int i = 0; i < scale; i++) 8 | { 9 | for (int j = 0; j < scale; j++) 10 | { 11 | printf("%02d", num); 12 | num++; 13 | } 14 | printf("\n"); 15 | } 16 | printf("\n"); 17 | num = 1; 18 | for (int i = 0; i < scale; i++) 19 | { 20 | for (int j = 0; j < scale; j++) 21 | { 22 | if (j >= scale - i - 1) 23 | { 24 | printf("%02d", num); 25 | num++; 26 | } 27 | else 28 | { 29 | printf(" "); 30 | } 31 | } 32 | printf("\n"); 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /WHUT/2023/GPLT04/L1-7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int N; 9 | cin >> N; 10 | multiset a; 11 | for (int i = 0; i < N; i++) 12 | { 13 | int t; 14 | cin >> t; 15 | a.insert(t); 16 | } 17 | int mina = *a.begin(), maxa = *a.rbegin(); 18 | cout << mina << ' ' << a.count(mina) << endl 19 | << maxa << ' ' << a.count(maxa) << endl; 20 | } 21 | 22 | signed main() 23 | { 24 | ios::sync_with_stdio(false); 25 | cin.tie(0); 26 | cout.tie(0); 27 | solve(); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /WHUT/2022/Week02/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | bool h = true; 8 | char c; 9 | while ((c = getchar()) != EOF) 10 | { 11 | if (isalpha(c)) 12 | { 13 | if (h) 14 | { 15 | h = false; 16 | cout << char(toupper(c)); 17 | } 18 | else 19 | { 20 | cout << c; 21 | } 22 | } 23 | else if (c == ' ' || c == '\n') 24 | { 25 | h = true; 26 | cout << c; 27 | } 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/262/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define int long long 3 | 4 | using namespace std; 5 | 6 | const int MAXN = 5e5 + 10; 7 | int N; 8 | int a[MAXN]; 9 | 10 | signed main() 11 | { 12 | cin >> N; 13 | int same = 0; 14 | for (int i = 1; i <= N; i++) 15 | { 16 | cin >> a[i]; 17 | if (a[i] == i) 18 | same++; 19 | } 20 | int ans = 0; 21 | for (int i = 1; i <= N; i++) 22 | { 23 | if (a[i] != i && a[a[i]] == i) 24 | ans++; 25 | } 26 | ans /= 2; 27 | ans += same * (same - 1) / 2; 28 | cout << ans << endl; 29 | return 0; 30 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1161.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | bool light[2000100] = {false}; 8 | int n; 9 | cin >> n; 10 | while (n--) 11 | { 12 | double a; 13 | int t; 14 | cin >> a >> t; 15 | for (int i = 1; i <= t;i++) 16 | { 17 | light[(int)(a * i)] = (light[(int)(a * i)]) ? false : true; 18 | } 19 | } 20 | for (int i = 1; i <= 2000000;i++) 21 | { 22 | if(light[i]) 23 | { 24 | cout << i << endl; 25 | break; 26 | } 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /LuoGu/2000~2999/B2118.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | #define int long long 4 | 5 | using namespace std; 6 | 7 | void solve() 8 | { 9 | string s, t; 10 | cin >> s >> t; 11 | if (s.size() > t.size()) // s <= t 12 | swap(s, t); 13 | if (t.find(s) != s.npos) 14 | cout << s << " is substring of " << t << endl; 15 | else 16 | cout << "No substring" << endl; 17 | } 18 | 19 | signed main() 20 | { 21 | ios::sync_with_stdio(false); 22 | cin.tie(0); 23 | cout.tie(0); 24 | int t = 1; 25 | // cin >> t; 26 | while (t--) 27 | solve(); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /WHUT/2021/TeamExercise_04/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | int T; 8 | cin >> T; 9 | for (int i = 1; i <= T; i++) 10 | { 11 | int n, k; 12 | cin >> n >> k; 13 | long long ans = 1; 14 | if (n >= k) 15 | { 16 | for (int j = 0; j < k; j++) 17 | { 18 | ans *= (n - j); 19 | } 20 | for (int p = 2; p <= k; p++) 21 | { 22 | ans /= p; 23 | } 24 | for (int j = 0; j < k; j++) 25 | { 26 | ans *= (n - j); 27 | } 28 | } 29 | else 30 | { 31 | ans = 0; 32 | } 33 | cout << "Case " << i << ": " << ans << endl; 34 | } 35 | return 0; 36 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/248/D_TLE.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | ios::sync_with_stdio(false); 8 | cin.tie(0); 9 | int N; 10 | cin >> N; 11 | vector A(N); 12 | for (int i = 0; i < N; i++) 13 | cin >> A[i]; 14 | int Q; 15 | cin >> Q; 16 | while (Q--) 17 | { 18 | int L, R, X; 19 | cin >> L >> R >> X; 20 | int ans = 0; 21 | for (int i = L - 1; i < R; i++) 22 | { 23 | if (A[i] == X) 24 | ans++; 25 | } 26 | cout << ans << endl; 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/269/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | ios::sync_with_stdio(false); 8 | long long N; 9 | cin >> N; 10 | vector onebit; 11 | for (int i = 0; i < 60; i++) 12 | if (N >> i & 1) 13 | onebit.push_back(i); 14 | for (int i = 0; i < (1LL << onebit.size()); i++) 15 | { 16 | long long num = 0; 17 | for (int j = 0; j < onebit.size(); j++) 18 | if (i >> j & 1) 19 | num += 1LL << onebit[j]; // num += pow(2, onebit[j]); 20 | cout << num << endl; 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Other/Educational #149 (Rated for Div. 2)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int x, k; 9 | cin >> x >> k; 10 | if (x % k) 11 | { 12 | cout << 1 << endl 13 | << x << endl; 14 | } 15 | else 16 | { 17 | cout << 2 << endl 18 | << 1 << ' ' << x - 1 << endl; 19 | } 20 | } 21 | 22 | signed main() 23 | { 24 | ios::sync_with_stdio(false); 25 | cin.tie(0); 26 | cout.tie(0); 27 | int t; 28 | cin >> t; 29 | while (t--) 30 | solve(); 31 | return 0; 32 | } -------------------------------------------------------------------------------- /AcWing/800~899/867.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n; 8 | cin >> n; 9 | while (n--) 10 | { 11 | int a; 12 | cin >> a; 13 | for (int i = 2; i <= a / i; i++) 14 | { 15 | int cnt = 0; 16 | while (!(a % i)) 17 | { 18 | cnt++; 19 | a /= i; 20 | } 21 | if (cnt) 22 | cout << i << ' ' << cnt << endl; 23 | } 24 | if (a != 1) 25 | cout << a << ' ' << 1 << endl; 26 | cout << endl; 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Contest/AtCoder/Beginner/271/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | const int MAXN = 2e5 + 10; 6 | int N, Q; 7 | 8 | int main() 9 | { 10 | cin >> N >> Q; 11 | vector> seq(N); 12 | for (int i = 0; i < N; i++) 13 | { 14 | int t; 15 | cin >> t; 16 | while (t--) 17 | { 18 | int num; 19 | cin >> num; 20 | seq[i].push_back(num); 21 | } 22 | } 23 | for (int i = 0; i < Q; i++) 24 | { 25 | int s, t; 26 | cin >> s >> t; 27 | cout << seq[s - 1][t - 1] << endl; 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Misc/Completebag_Optimized.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | const int SIZE = 1010; 7 | int N, V; 8 | int v[SIZE], w[SIZE]; 9 | int dp[SIZE][SIZE]; 10 | 11 | int main() 12 | { 13 | cin >> N >> V; 14 | for (int i = 1; i <= N; i++) 15 | cin >> v[i] >> w[i]; 16 | for (int i = 1; i <= N; i++) 17 | { 18 | for (int j = 0; j <= V; j++) 19 | { 20 | dp[i][j] = dp[i - 1][j]; 21 | if (j >= v[i]) 22 | dp[i][j] = max(dp[i][j], dp[i][j - v[i]] + w[i]); 23 | } 24 | } 25 | cout << dp[N][V] << endl; 26 | return 0; 27 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_03/M.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int m, n, matrix[5][5], temp; 7 | for (int i = 0; i < 5; i++) 8 | { 9 | for (int j = 0; j < 5; j++) 10 | { 11 | scanf("%d", &matrix[i][j]); 12 | } 13 | } 14 | scanf("%d%d", &m, &n); 15 | m--; 16 | n--; 17 | for (int i = 0; i < 5; i++) 18 | { 19 | temp = matrix[m][i]; 20 | matrix[m][i] = matrix[n][i]; 21 | matrix[n][i] = temp; 22 | } 23 | for (int i = 0; i < 5; i++) 24 | { 25 | for (int j = 0; j < 5; j++) 26 | { 27 | printf("%d ", matrix[i][j]); 28 | } 29 | printf("\n"); 30 | } 31 | system("pause"); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /WHUT/2022/Week01/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int t; 8 | while (cin >> t) 9 | { 10 | if (90 <= t && t <= 100) 11 | cout << "A" << endl; 12 | else if (80 <= t && t <= 89) 13 | cout << "B" << endl; 14 | else if (70 <= t && t <= 79) 15 | cout << "C" << endl; 16 | else if (60 <= t && t <= 69) 17 | cout << "D" << endl; 18 | else if (0 <= t && t <= 59) 19 | cout << "E" << endl; 20 | else 21 | cout << "Score is error!" << endl; 22 | } 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#831 (Div. 1 + Div. 2)/_C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define int long long 3 | 4 | using namespace std; 5 | 6 | void solve() 7 | { 8 | int n; 9 | cin >> n; 10 | vector a(n); 11 | for (int i = 0; i < n; i++) 12 | cin >> a[i]; 13 | sort(a.begin(), a.end()); 14 | int ans = a.back() - a.front(); 15 | for (int i = 1; i < n; i++) 16 | ans = max({ans, a.back() + a[i] - 2 * a[i - 1], 2 * a[i] - a.front() - a[i - 1]}); 17 | cout << ans << endl; 18 | } 19 | 20 | signed main() 21 | { 22 | int t; 23 | cin >> t; 24 | while (t--) 25 | solve(); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Contest/Codeforces/Regular/#867 (Div. 3)/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define endl '\n' 3 | 4 | using namespace std; 5 | 6 | typedef long long ll; 7 | 8 | void solve() 9 | { 10 | int n; 11 | cin >> n; 12 | vector a(n); 13 | for (int i = 0; i < n; i++) 14 | cin >> a[i]; 15 | sort(a.begin(), a.end()); 16 | ll ans = max(a[0] * a[1], a[a.size() - 1] * a[a.size() - 2]); 17 | cout << ans << endl; 18 | } 19 | 20 | signed main() 21 | { 22 | ios::sync_with_stdio(false); 23 | cin.tie(0); 24 | cout.tie(0); 25 | int t; 26 | cin >> t; 27 | while (t--) 28 | solve(); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /LuoGu/1000~1999/P1765.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(void) 6 | { 7 | map key; 8 | key['a'] = key['d'] = key['g'] = key['j'] = key['m'] = key['p'] = key['t'] = key['w'] = key[' '] = 1; 9 | key['b'] = key['e'] = key['h'] = key['k'] = key['n'] = key['q'] = key['u'] = key['x'] = 2; 10 | key['c'] = key['f'] = key['i'] = key['l'] = key['o'] = key['r'] = key['v'] = key['y'] = 3; 11 | key['s'] = key['z'] = 4; 12 | string str; 13 | getline(cin, str); 14 | int cnt = 0; 15 | for (int i = 0; i < str.length(); i++) 16 | { 17 | cnt += key[str[i]]; 18 | } 19 | cout << cnt << endl; 20 | return 0; 21 | } -------------------------------------------------------------------------------- /WHUT/2021/Week_03/I.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int count, old; 7 | double c1 = 0, c2 = 0, c3 = 0, c4 = 0; 8 | scanf("%d", &count); 9 | for (int i = 0; i < count; i++) 10 | { 11 | scanf("%d", &old); 12 | if (old >= 0 && old <= 18) 13 | c1++; 14 | else if (old >= 19 && old <= 35) 15 | c2++; 16 | else if (old >= 36 && old <= 60) 17 | c3++; 18 | else 19 | c4++; 20 | } 21 | printf("%.2lf%%\n", c1 / count * 100); 22 | printf("%.2lf%%\n", c2 / count * 100); 23 | printf("%.2lf%%\n", c3 / count * 100); 24 | printf("%.2lf%%", c4 / count * 100); 25 | system("pause"); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /WHUT/2022/Week04/L.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int t; 8 | cin >> t; 9 | while (t--) 10 | { 11 | int n; 12 | cin >> n; 13 | vector num(n); 14 | for (int i = 0; i < n; i++) 15 | cin >> num[i]; 16 | int nmin = INT32_MAX; 17 | for (int i = 0; i < n; i++) 18 | nmin = min(nmin, num[i]); 19 | int part = nmin * 2 - 1; 20 | int cnt = 0; 21 | for (int i = 0; i < n; i++) 22 | cnt += ceil(1.0 * num[i] / part) - 1; 23 | cout << cnt << endl; 24 | } 25 | return 0; 26 | } --------------------------------------------------------------------------------