tags: PAT cc++ Programming language programming oj
#include <cstdio>
const int MAXN = 1005;
struct Stu{
long long num1;
int num2;
int num3;
}stu[MAXN];
int main(){
int n;
scanf("%d", &n);
for(int i = 0; i < n; i++){
long long n1;
int n2, n3;
scanf("%lld%d%d", &n1, &n2, &n3);
stu[i].num1 = n1;
stu[i].num2 = n2;
stu[i].num3 = n3;
}
int k;
scanf("%d", &k);
for(int i = 0; i < k; i++){
int n2;
scanf("%d", &n2);
for(int i = 0; i < 1001; i++){
if(stu[i].num2 == n2){
printf("%lld %d\n", stu[i].num1, stu[i].num3);
}
}
}
return 0;
}
#include <cstdio>
#include <cstring>
const int maxn = 1010;
char str[maxn];
int hashTable[30] = {0};
int main(){
gets(str);
int len = strlen(str);
for(int i = 0; i < len; i++){
if(str[i] >= 'a' && str[i] <= 'z'){
hashTable[str[i] - 'a']++;
}
else if(str[i] >= 'A' && str[i] <= 'Z'){
hashTable[str[i] - 'A']++;
}
}
int k = 0;
for(int i = 0; i < 26; i++){
if(hashTable[i] > hashTable[k]){
k = i;
}
}
printf("%c %d\n", 'a' + k, hashTable[k]);
return 0;
}
#include <cstdio>
#include <cstring>
int hashTable[128] = {0};
char str[10010];
int main(){
gets(str);
int len = strlen(str);
for(int i = 0; i < len; i++){
hashTable[str[i]]++;
}
for(int i = 0; i < 10010; i++){
if(hashTable['P'] != 0){
printf("P");
hashTable['P']--;
}
if(hashTable['A'] != 0){
printf("A");
hashTable['A']--;
}
if(hashTable['T'] != 0){
printf("T");
hashTable['T']--;
}
if(hashTable['e'] != 0){
printf("e");
hashTable['e']--;
}
if(hashTable['s'] != 0){
printf("s");
hashTable['s']--;
}
if(hashTable['t'] != 0){
printf("t");
hashTable['t']--;
}
}
return 0;
}
#include <cstdio>
#include <iostream>
#include <string>
#include <map>
using namespace std;
string unitDigit[13] = {"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
string tenDigit[13] = {"tret", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
string numToStr[170];
map<string, int> strToNum;
void init(){
for(int i = 0; i < 13; i++){
numToStr[i] = unitDigit[i];
strToNum[unitDigit[i]] = i;
numToStr[i * 13] = tenDigit[i];
strToNum[tenDigit[i]] = i * 13;
}
for(int i = 1; i < 13; i++){
for(int j = 1; j < 13; j++){
string str = tenDigit[i] + " " + unitDigit[j];
numToStr[i * 13 + j] = str;
strToNum[str] = i * 13 + j;
}
}
}
int main(){
init();
int T;
scanf("%d%*c", &T);
while(T--){
string str;
getline(cin, str);
if(str[0] >= '0' && str[0] <= '9'){
int num = 0;
for(int i = 0; i < str.length(); i++){
num = num * 10 + (str[i] - '0');
}
cout << numToStr[num] << endl;
}
else{
cout << strToNum[str] << endl;
}
}
return 0;
}
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 100010;
const int INF = 0x3fffffff;
int a[MAXN], leftMax[MAXN], rightMin[MAXN];
int ans[MAXN], num = 0;
int main(){
int n;
scanf("%d", &n);
for(int i = 0; i < n; i++){
scanf("%d", &a[i]);
}
leftMax[0] = 0;
for(int i = 0; i < n; i++){
leftMax[i] = max(leftMax[i - 1], a[i - 1]);
}
rightMin[n - 1] = INF;
for(int i = n - 2; i >= 0; i--){
rightMin[i] = min(rightMin[i + 1], a[i + 1]);
}
for(int i = 0; i < n; i++){
if(leftMax[i] < a[i] && rightMin[i] > a[i]){
ans[num++] = a[i];
}
}
printf("%d\n", num);
for(int i = 0; i < num; i++){
printf("%d", ans[i]);
if(i < num - 1) printf(" ");
}
printf("\n");
return 0;
}
Title Description There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot a...
There is a classic division process in the famous rapid sorting algorithm: We usually take a method to take an element as the main element, by exchange, put the elements of the larger element in its l...
[PAT B1041] Exam seat number Description of the topic 1041 Exam Seat Number (15 points) Each PAT candidate will be assigned two seat numbers when taking the test, one for the test seat and one for the...
Title link->link Ideas Structure storage, note that the character array should be opened to 17 bits. Code...
1041. Exam seat number (15) time limit 400 ms Memory limit 65536 kB Code length limit 8000 B Judgment procedure Standard Author CHEN, Yue Each PAT candidate will be assigned two seat numbers when taki...
Topic link...
Each PAT candidate will be assigned two seat numbers when taking the exam, one is a test seat, one is a test seating. Under normal circumstances, candidates first get the test seat number, after enter...
Topic description B1045 Think 1. The front largest number of <= main element <= the minimum number of times 2. Find the minimum number of backs from all positions, put in array, easy to find 3. ...
PAT Each candidate will be assigned seat number two in the exam, the test machine is a seat, a seat is exam. Under normal circumstances, the first candidates in the admission test machine to obtain a ...
There is a pit point where the format is output. If it is 0, the newline character has to be output 2 (that is, the second line of the line is output when it is output)...