1154. Easy sort |
|
|
Total: |
6575 |
Accepted: |
1998 |
Rating: |
2.7/5.0 (67 votes) |
|
|
|
|
|
|
|
|
|
|
Time Limit: 1 s memory limit: 32 MB description You know sorting is very Important. And this easy problem is: Given you an array with N Non-negative integers which are smaller than 10,000,000, You have to sort this Array. Sorting means that integer with smaller value presents First. InputThe first line of the input is a positive Integer T. T is the number of the test cases followed. The first Line of each test case is a positive integer N (1 <= N <= 1000) which represents the number of integers in the array. After That, n lines followed. the I-th line is the I-th integer in Array. Outputthe output of each test case shoshould consist of N Lines. the I-th line is the I-th INTEGER OF THE array after sorting. No Redundant spaces are needed. sample input Copy sample input to clipboard2312311 Sample output1231 |
# Include <stdio. h>
Int main ()
{
Int
Cou, N, I, J, K, num [1000] = {0}, temp;
Scanf ("% d", & cou );
For (I = 0; I <cou; I ++)
{
Scanf ("% d", & N );
For (j = 0; j <n; j ++)
Scanf ("% d", & num [J]);
For (j = 0; j <n; j ++)
For (k = J; k <n-1; k ++)
If (Num [J]> num [k + 1])
{Temp = num [k + 1];
Num [k + 1] = num [J];
Num [J] = temp;
}
For (j = 0; j <n; j ++)
Printf ("% d/N", num [J]);
For (j = 0; j <n; j ++)
Num [J] = 0;
}
}
1200. Stick |
|
|
Total: |
2912 |
Accepted: |
1346 |
Rating: |
1.7/5.0 (15 votes) |
|
|
|
|
|
|
|
|
|
|
Time Limit: 1 s memory limit: 32 MB description Anthony has collected a large amount Sticks for manufacturing chopsticks. In order to simplify his job, he wants Fetch two equal-length sticks for Machining at a time. After checking it over, Anthony finds that it is always possible that only one stick is left at last, Because of the odd number of sticks and some other unknown reasons. For example, Anthony may have three sticks with length 1, 2, and 1 respectively. He fetches The first and the third for machining, and leaves the second one at last. You Task is to report the length of the last stick. InputThe input file will Consist of several cases. Each case will be Presented by an integer N (1 <= n <= 100, and N is odd) at first. Following That, n positive integers will be given, one in a line. These numbers indicate The length of the sticks collected by Anthony. The input is ended N = 0. OutputFor each case, output An integer in a line, which is the length of the last Stick. Sample Input Copy sample input to clipboard31210 Sample output2 |
# Include <stdio. h>
Int main ()
{
Int I, j, N;
Int
A [100] = {0 };
While (1)
{Scanf ("% d", & N );
If (N % 2 = 0 | n <1 | n> 100)
Break;
Else
{
For (I = 0; I <n; I ++)
Scanf ("% d", & A [I]);
For (I = 0; I <n-1; I ++)
For (j = I; j <n-1; j ++)
If (A [I] = A [J + 1])
{A [I] = 0; A [J + 1] = 0 ;}
For (I = 0; I <n; I ++)
If (A [I]! = 0)
Printf ("% d/N", a [I]);
}
}
}
1324. Score |
|
|
Total: |
1865 |
Accepted: |
1094 |
Rating: |
2.9/5.0 (7 votes) |
|
|
|
|
|
|
|
|
|
|
Time Limit: 1 s memory limit: 32 MB description There is an objective test result such''Ooxxoxxooo".'O'Means a correct answer of a problem and An'X'Means a wrong answer. Score of each problem of this test is calculated by itself and its just previous Consecutive'O'S only when Answer is correct. For example, the score of the 10th problem is 3 that is Obtained by itself and its two previous consecutive'O'S. Therefore, the score''Ooxxoxxooo"Is 10 which is calculated ''1 + 2 + 0 + 0 + 1 + 0 + 0 + 1 + 2 + 3 ". You are writing a program calculating the scores of test results. InputYour program is to read from standard input. The input consistsTTest Cases. The number of test casesT Is given in the first line The input. Each test case starts with a line containing a string composed `OAnd'XAnd the length of the string is more Than 0 and less than 80. There is no spaces'OAnd'X'. OutputYour program is to write to standard output. Print exactly one line for each Test case. The line is to contain the score of the test case. The following shows sample input and output for five test cases. Sample Input Copy sample input to clipboard5 OOXXOXXOOO OOXXOOXXOO OXOXOXOXOXOXOX OOOOOOOOOO OOOOXOOOOXOOOOX Sample output10 9 7 55 30 #include<stdio.h> int main() { int n[100]={0},counter=0,bou,i,j,k; char c[81]; scanf("%d",&bou); while(1) { if(counter>=bou) break; counter++; scanf("%s",c); for(i=0,j=0;c[i]!='/0';i++,j++) { k=i; while(c[i]=='O'&&i>=0) { n[j]++; i--; } i=k; }
for(i=0,k=0;i<j;i++) k=k+n[i];
printf("%d/n",k); for(i=0;i<100;i++) n[i]=0;
} return 0; } |