66 solutions
-
-1
Here is the translation of the provided text:
100 Accepted A1000 【Example】Hello, World! Grammar 99 / 340 Beginner 100 Accepted A1001 【Example】A + B Problem Grammar 92 / 177 Beginner 100 Accepted A1002 Area of a Square 91 / 181 Beginner 100 Accepted A1003 Movie Tickets Grammar Basic Data Types 88 / 200 Beginner 100 Accepted A1004 Area of a Rectangle 89 / 115 Beginner 100 Accepted A1005 Perimeter of a Rectangle 88 / 122 Beginner 100 Accepted A1006 【Example】Division with Remainder 86 / 128 Beginner 100 Accepted A1007 Breaking Down Numbers and Summing Them 86 / 136 Beginner 100 Accepted A1008 Reverse Output a Three-Digit Number Breaking Down Numbers 85 / 197 Beginner 100 Accepted A1009 Reverse Output a Four-Digit Integer Breaking Down Numbers 78 / 245 Beginner 100 Accepted A1010 [ABC222A] Four Digits (Four Digits) 40 / 54 Beginner 100 Accepted A1011 【Example】Swapping Values Water Pouring Problem 81 / 197 Beginner 100 Accepted A1012 Cows Eating Grass Elementary Math Olympiad 72 / 119 Popularization- 100 Accepted A1013 Cuboid 78 / 250 Beginner 100 Accepted A1015 【Example】Floating Point Number with 3 Decimal Places 78 / 158 Beginner 100 Accepted A1016 Calculating the Floating Point Value of a Fraction 78 / 167 Beginner 100 Accepted A1017 Estimation of Earth's Population Carrying Capacity 57 / 152 Popularization- 100 Accepted A1018 Calculations Related to Circles 74 / 263 Beginner 100 Accepted A1019 Temperature Expression Conversion 73 / 197 Beginner 100 Accepted A1020 [ABC226A] Rounding Decimals (Round decimals) 41 / 54 Beginner 100 Accepted A1021 【Example】Size of Integer Data Type Storage Space 73 / 144 Beginner 100 Accepted A1022 Rounding Floating Point Numbers Towards Zero 71 / 136 Beginner 100 Accepted A1024 Print ASCII Code 75 / 159 Beginner 100 Accepted A1025 Print Character 71 / 134 Beginner 100 Accepted A1026 Size of Floating Point Data Type Storage Space
-
-1
#include<bits/stdc++.h> using namespace std; const int N=1001; struct Student { int name; double sc; }s[N]; bool cmp(Student a,Student b) { if(a.sc>b.sc) return 1; if(a.sc==b.sc&&a.name<b.name) return 1; return 0; } int main() { int n,m; cin>>n>>m; for(int i=1;i<=n;i++) { cin>>s[i].name>>s[i].sc; } sort(s+1,s+n+1,cmp); cout<<s[m].name<<" "<<s[m].sc; }
-
-3
#include<bits/stdc++.h> using namespace std; // 全局变量定义区 int a[]={72,101,108,108,111,44,87,111,114,108,100,33}; int b[15]; int c[100]; int d[100]; int e[100]; int f[100]; int g[100]; int h[100]; int I[100]; int j[100]; int k[100]; int l[100]; int m[100]; int n[100]; int o[100]; int p[100]; int q[100]; int r[100]; int s[100]; int t[100]; int u[100]; int v[100]; int w[100]; int x[100]; int y[100]; int z[100]; // 函数声明区 void initArrays(); void copyArray(int src[], int dest[], int size); void printArrayAsChars(int arr[], int size); void doNothing(); void complicatedLoop(int arr[], int size); void superComplicatedLogic(int arr1[], int arr2[], int size); void mysteryFunction(int arr[], int size); void anotherMysteryFunction(int arr[], int size); void andAnotherOne(int arr[], int size); void justBecauseWeCan(int arr[], int size); void whyNot(int arr[], int size); void whatIsThis(int arr[], int size); void seriously(int arr[], int size); void thisIsGettingRidiculous(int arr[], int size); void butWeAreNotDoneYet(int arr[], int size); void almostThere(int arr[], int size); void oneMoreFunction(int arr[], int size); void okLastOne(int arr[], int size); int main() { // 初始化所有数组 initArrays(); // 复杂的数组复制操作 copyArray(a, b, 12); // 对空数组进行一些操作 complicatedLoop(c, 100); complicatedLoop(d, 100); complicatedLoop(e, 100); // 超级复杂的逻辑处理 superComplicatedLogic(b, c, 12); // 一些毫无意义的函数调用 doNothing(); mysteryFunction(f, 100); anotherMysteryFunction(g, 100); andAnotherOne(h, 100); justBecauseWeCan(I, 100); whyNot(j, 100); whatIsThis(k, 100); seriously(l, 100); thisIsGettingRidiculous(m, 100); butWeAreNotDoneYet(n, 100); almostThere(o, 100); oneMoreFunction(p, 100); okLastOne(q, 100); // 最终打印结果 printArrayAsChars(b, 12); return 0; } void initArrays() { for(int i = 0; i < 100; i++) { c[i] = 0; d[i] = 0; e[i] = 0; f[i] = 0; g[i] = 0; h[i] = 0; I[i] = 0; j[i] = 0; k[i] = 0; l[i] = 0; m[i] = 0; n[i] = 0; o[i] = 0; p[i] = 0; q[i] = 0; r[i] = 0; s[i] = 0; t[i] = 0; u[i] = 0; v[i] = 0; w[i] = 0; x[i] = 0; y[i] = 0; z[i] = 0; } } void copyArray(int src[], int dest[], int size) { for(int i = 0; i < size; i++) { dest[i] = src[i]; } } void printArrayAsChars(int arr[], int size) { for(int i = 0; i < size; i++) { cout << char(arr[i]); } } void doNothing() { // 这个函数什么都不做,只是为了增加代码行数 int a = 0; a++; a--; if(a == 0) { // 空块 } } void complicatedLoop(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] + 0; } } void superComplicatedLogic(int arr1[], int arr2[], int size) { for(int i = 0; i < size; i++) { arr2[i] = arr1[i] + 0; } } void mysteryFunction(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] * 1; } } void anotherMysteryFunction(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] / 1; } } void andAnotherOne(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] - 0; } } void justBecauseWeCan(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] + (0 * i); } } void whyNot(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] - (0 * i); } } void whatIsThis(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] * (1 + 0); } } void seriously(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] / (1 - 0); } } void thisIsGettingRidiculous(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] + (i * 0); } } void butWeAreNotDoneYet(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] - (i * 0); } } void almostThere(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] * (1 + (0 * i)); } } void oneMoreFunction(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] / (1 - (0 * i)); } } void okLastOne(int arr[], int size) { for(int i = 0; i < size; i++) { arr[i] = arr[i] + 0; } }
-
-5
-
-7
-
-7
#include <iostream> using namespace std; int main() { int n, i, j; cin >> n >> i >> j; // 输出同一行上的格子位置 cout << "同一行上格子的位置:" << endl; for (int k = 1; k <= n; k++) { cout << "(" << i << "," << k << ") "; } cout << endl; // 输出同一列上的格子位置 cout << "同一列上格子的位置:" << endl; for (int k = 1; k <= n; k++) { cout << "(" << k << "," << j << ") "; } cout << endl; // 输出左上到右下对角线上的格子位置 cout << "左上到右下对角线上的格子的位置:" << endl; for (int k = 1; k <= n; k++) { int row = i - (i - 1) + k; // 从i开始,每次递增1 int col = j - (j - 1) + k; // 从j开始,每次递增1(这里其实简化为k,但为了与下面的对称,保持这种形式) // 但由于我们只需要对角线上的点,且行列从1开始,所以只需考虑row=col的情况 // 当k=1时,row=i, col=j(即起点),之后每次移动都是row和col同时增减(但在这个特定情况下,我们只需考虑增加) // 所以我们只需要检查row(或col,因为它们应该相等)是否不超过n if (row <= n && row == (i - (i - k) + (j - (j - k)))) { // 这里其实row==col+k-i+i-k==col(简化后)且row<=n // 但由于我们是从i,j出发,所以只需考虑row从i开始且不超过n的情况 // 因此上面的条件可以简化为row==i+k-1且row<=n(但k从1开始,所以row从i递增到不超过n) // 但为了与题目要求的对角线逻辑一致(虽然这里有些冗余),我们还是用row==col的形式来表示 // 不过由于我们已经知道起点是(i,j),所以直接计算col=i+k-j(当row=i+k-1时,因为row==col) // 并检查col是否不超过n即可(但这里为了与下面的代码风格一致,我们还是用row来表示) // 注意:这里的解释有些冗长和复杂,实际上只需知道从(i,j)出发,沿对角线移动即可 // 正确的简化逻辑应该是:直接计算对角线上的点(i+d, j+d)或(i-d, j-d),其中d是从0开始的偏移量 // 但由于我们已经知道起点,且只考虑正向对角线(即从左上到右下),所以只需(i+d, j+d)且d<n-i+1且d<n-j+1 // 但为了与题目和下面的代码一致,我们还是用下面的形式来表示 int actualCol = i + k - 1 - (i - 1); // 简化后为k(因为是从i开始)但这里为了与row的计算形式一致而写成这样 if (actualCol == j + k - 1 - (j - 1) && actualCol <= n) { // 实际上只需检查row(或col)是否不超过n且row==col(在这里的形式下) // 但由于上面的计算已经保证了row==col(当从(i,j)出发时),所以我们只需检查是否不超过n cout << "(" << row << "," << actualCol << ") "; // 这里actualCol其实等于row,但为了与上面的计算一致而保留 } // 注意:上面的条件判断有些冗余,实际上只需检查row(或col)的值即可 // 正确的简化应该是直接输出(i+k-1, j+k-1)且k从1递增到使得i+k-1和j+k-1都不超过n为止 // 但为了与题目要求和下面的代码风格一致,我们还是保留了上面的形式 // 下面的代码将直接采用简化的逻辑来输出对角线上的点 // 实际上,从(i,j)出发的对角线上的点应该是(i+d, j+d),其中d是从0到某个值的范围 // 所以我们可以直接这样计算并输出: cout << "(" << i + k - 1 << "," << j + k - 1 << ") "; // 正确的对角线输出逻辑 // 注意:上面的输出中,我们直接计算了对角线上的点,而没有使用上面的冗余判断 // 这是因为我们已经知道起点是(i,j),且只考虑正向对角线(从左上到右下) // 所以我们只需从i和j开始,每次同时增加相同的值(即d),直到达到或超过n为止(但不超过的部分才是有效的点) } // 注意:上面的解释部分是为了展示思考过程,实际代码中应该直接采用简化的逻辑来输出对角线上的点 // 下面的代码将直接跳过上面的冗余部分,并正确输出对角线上的点 } // 注意:上面的循环中,我们实际上多输出了一些不必要的判断和解释 // 为了简洁和正确,我们应该直接这样输出对角线上的点: for (int d = 0; i + d <= n && j + d <= n; d++) { // d表示从(i,j)出发的偏移量 cout << "(" << i + d << "," << j + d << ") "; // 直接计算并输出对角线上的点 } // 注意:上面的循环才是正确的对角线输出逻辑,它直接计算了从(i,j)出发的对角线上的所有点 // 并输出了它们的位置。之前的循环和判断是为了展示思考过程,实际代码中应该采用这个简化的逻辑。 cout << endl; // 输出换行符以分隔不同的输出部分 // 输出左下到右上对角线上的格子位置(注意这里的逻辑与上面类似,但方向相反) cout << "左下到右上对角线上的格子的位置:" << endl; for (int d = 0; i - d >= 1 && j + d <= n; d++) { // d表示从(i,j)出发的偏移量(但这次是向左下方向偏移的负值,但在计算中我们取正值,并在输出时调整行列) cout << "(" << i - d << "," << j + d << ") "; // 直接计算并输出对角线上的点(注意行列的调整) } // 注意:上面的循环正确地输出了从(i,j)出发的左下到右上对角线上的所有点 // 它通过调整d的值来遍历对角线上的所有点,并输出了它们的位置。 cout << endl; // 输出换行符以结束程序输出。 return 0; }
-
-7
Information
- ID
- 838
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 2
- Tags
- # Submissions
- 342
- Accepted
- 99
- Uploaded By