A
非常简单的签到题
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
int t,n,m;
string a;
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&m);
cin>>a;
for(int i = 0;i<n;++i){
for(int j = 0;j<m;++j){
cout<<a[i*m+j];
}
cout<<endl;
}
}
return 0;
}
B(数学 进制转化)
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <string>
#include <queue>
using namespace std;
const int MAXN = 100 + 5;
int d[MAXN * 2];
struct D
{
int u, v;
bool operator < (const D& rbs)const{
return v < rbs.v;
}
};
priority_queue<D>que;
bool valid(int &l, int &r)
{
int ok = 0;
for(int i = l + 1 ; i <= r ; i++){
// printf("i = %d\n", i);
if(d[i] == 1 && d[i - 1] == 1){
d[i] = 0, d[i - 1] = 0;
d[i + 1]++;
if(r < i + 1) r = i + 1;
if(i == l) l = i + 1;
ok = 1;
}
else if(d[i] > 1){
que.push(D{i, d[i]});
ok = 1;
}
}
return ok;
}
void check(int l, int r)
{
for(int i = l ; i <= r ; i++) printf("%d", d[i]);
printf("\n");
}
int main()
{
int u;
while(scanf("%d", &u) != EOF){
if(u == 1){
printf("1\n");
continue;
}
memset(d, 0, sizeof(d));
while(!que.empty()) que.pop();
que.push(D{MAXN - 1, u});
que.push(D{MAXN - 2, u});
d[MAXN - 1] = d[MAXN - 2] = u;
int head, rear;
head = MAXN - 2, rear = MAXN - 1;
int flag = 1;
while(flag){
flag = 0;
for(int i = head ; i <= rear ; i++){
if(d[i] > 1){
d[i + 1] += d[i] / 2;
d[i - 2] += d[i] / 2;
d[i] %= 2;
head = min(head, i - 2);
rear = max(rear, i + 1);
flag = 1;
}
}
for(int i = head ; i <= rear ; i++){
int temp = min(d[i], d[i - 1]);
if(temp > 0){
d[i + 1] += temp;
d[i] -= temp;
d[i - 1] -= temp;
flag = 1;
rear = max(rear, i + 1);
}
}
while(d[head] == 0) head++;
while(d[rear] == 0) rear--;
}
while(d[head] == 0) head++;
while(d[rear] == 0) rear--;
for(int i = rear ; i >= head ; i--){
printf("%d", d[i]);
if(i == MAXN) printf(".");
}
printf("\n");
// printf("head = %d, rear = %d\n", head, rear);
}
return 0;
}