原题地址
A题
题意:排序
思路:主要卡时间,用快读
代码:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
inline int read() {
int num=0, w=0;
char ch=0;
while (!isdigit(ch)) {
w|=ch=='-';
ch = getchar();
}
while (isdigit(ch)) {
num = (num<<3) + (num<<1) + (ch^48);
ch = getchar();
}
return w? -num: num;
}
//快速写
inline void write(int x)
{
if(x<0) {
putchar('-');
x = -x;
}
if(x>9) write(x / 10);
putchar(x % 10 + '0');
}
int arr[1000000];
int main()
{
int n, k;n = read();
while(n--){
int t = read();
for(int i=0;i<t;i++){
arr[i]=read();
}
sort(arr,arr+t);
for(int i=0;i<t;i++){
if(i)printf(" ");
write(arr[i]);
}printf("\n");
}
return 0;
}
B题
题意:给你n,m,然后让你分两组,一组是能被m整除的,两组是其他的
思路:一开始超时了在我直接遍历找能被整除的数,后来换了一种写法,就过了
代码:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
inline int read() {
int num=0, w=0;
char ch=0;
while (!isdigit(ch)) {
w|=ch=='-';
ch = getchar();
}
while (isdigit(ch)) {
num = (num<<3) + (num<<1) + (ch^48);
ch = getchar