ACdream区域赛指导赛之手速赛系列(5) 解题报告 A C D

Problem A

题意:就是进制转换,在不同进制不同符号系统间转换,数字符号不一定是通常使用的0123,由一个字符串给出。
思路:水题,符号系统长度是几就是几进制,转好之后用相应的符号输出就可以了。

/*
* this code is made by squee_spoon
* Problem: 1038
* Verdict: Accepted
* Submission Date: 2014-08-22 19:41:23
* Time: 0MS
* Memory: 1676KB
*/
#include <iostream>   
#include <stdio.h>   
#include <cmath>   
#include <algorithm>   
#include <iomanip>   
#include <cstdlib>   
#include <string>   
#include <memory.h>   
#include <vector>   
#include <queue>   
#include <stack>   
#include <map> 
#include <set> 
#include <ctype.h>   
#include <sstream>
#define INF 1000000
#define ll long long
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define MAXN 100010
 
using namespace std; 
 
int main() {
    int t;
    cin>>t;
    int _case=0;
    while(t--){
        _case++;
         
        string num;
        string s;
        string t;
        cin>>num>>s>>t;
        int lens=s.size();
        int lent=t.size();
        int lennum=num.size();
        //源转10进制
        ll s10=0;
         
        for(int i=0;i<lennum;i++){
            s10*=lens;
            int end=s.size();
            int j;
            for(j=0;j<end;j++){
                if(num[i]==s[j])break;
            }
            s10+=(j);
        }
         
        ll tmp=1;
        int k=0;
        while(tmp<=s10){
            tmp*=lent;
            k++;
        }
         
         
        tmp/=lent;
        printf("Case #%d: ",_case);
        if(s10==0)cout<<t[0];
        for(int i=k;i>0;i--){
            int cnt=0;
            while(s10-tmp>=0){
                s10-=tmp;
                cnt++;
            }
            tmp/=lent;
            cout<<t[cnt];
        }
         
        cout<<endl;
    }
    return 0;
}

Problem C

题意:给字符串做插入排序。。问要移动几次。。
思路:水题。记录当前最后一个字符串,如果下一个小于它,次数+1。

/*
* this code is made by squee_spoon
* Problem: 1146
* Verdict: Accepted
* Submission Date: 2014-08-22 20:02:19
* Time: 12MS
* Memory: 1676KB
*/
#include <iostream>   
#include <stdio.h>   
#include <cmath>   
#include <algorithm>   
#include <iomanip>   
#include <cstdlib>   
#include <string>   
#include <memory.h>   
#include <vector>   
#include <queue>   
#include <stack>   
#include <map> 
#include <set> 
#include <ctype.h>   
#include <sstream>
#define INF 1000000
#define ll long long
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define MAXN 100010
 
using namespace std; 
 
int main() {
    int t;
    cin>>t;
    int _case=0;
    while(t--){
        _case++;
        int n;
        cin>>n;
        string str;
        string last;
        getline(cin,last);
        getline(cin,last);
        int ans=0;
        for(int i=2;i<=n;i++){
            getline(cin,str);
            if(last>str){
                ans++;
            }else{
                last=str;
            }
        }
        printf("Case #%d: ",_case);
        cout<<ans<<endl;
    }
    return 0;
}

Problem D

题意:给一串数字排序。排好后原来是奇数的位置还是奇数,是偶数的位置还是偶数。其中奇数升序,偶数降序。
思路:水题。。

/*
* this code is made by squee_spoon
* Problem: 1189
* Verdict: Accepted
* Submission Date: 2014-08-22 20:15:09
* Time: 8MS
* Memory: 1684KB
*/
#include <iostream>   
#include <stdio.h>   
#include <cmath>   
#include <algorithm>   
#include <iomanip>   
#include <cstdlib>   
#include <string>   
#include <memory.h>   
#include <vector>   
#include <queue>   
#include <stack>   
#include <map> 
#include <set> 
#include <ctype.h>   
#include <sstream>
#define INF 1000000
#define ll long long
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define MAXN 100010
 
using namespace std; 
 
int books[1010];
 
int main() {
    int t;
    cin>>t;
    int _case=0;
    while(t--){
        _case++;
         
        vector<int> A;
        vector<int> B;
        int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>books[i];
            if(books[i]&1){
                A.push_back(books[i]);
            }else{
                B.push_back(books[i]);
            }
        }
        sort(A.begin(),A.end());
        sort(B.begin(),B.end());
         
        printf("Case #%d: ",_case);
        int ka=0,kb=B.size()-1;
        for(int i=1;i<=n;i++){
            if(books[i]&1){
                cout<<A[ka++];
            }else{
                cout<<B[kb--];
            }
            if(i!=n)cout<<" ";
        }
         
        cout<<endl;
    }
    return 0;
}



你可能感兴趣的:(ACdream)