首页 > 其他 > 详细

Gym - 101102B

时间:2018-01-22 15:12:53      阅读:220      评论:0      收藏:0      [点我收藏+]

注意到使用的代价均是2-7连续的,直接暴力必然有解

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
using namespace std;
const int maxn = 1e5+11;
const int oo = 0x3f3f3f3f;
int a[]={6,2,5,5,4,5,6,3,7,6};
char str[maxn];
int main(){
    ios::sync_with_stdio(0);
    int N,T; cin>>T;
    while(T--){
        cin>>N>>str;
        int tot=0;
        rep(i,0,N-1) tot+=a[str[i]-‘0‘];
        int tmp=tot;
        rep(i,1,N){
            rrep(j,9,0){
                int t=tot-a[j];
                if(t>=2*(N-i)&&t<=7*(N-i)){//note
                    cout<<j;
                    tot=t;
                    break;
                }
            }
        }
        cout<<endl;
    }
    return 0;
}

Gym - 101102B

原文:https://www.cnblogs.com/caturra/p/8329036.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!