2013 Asia Regional Changchun

6 篇文章 0 订阅

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;
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值