The 5th Zhejiang Provincial Collegiate Programming Contest(ZOJ2965—ZOJ2976)

Accurately Say "CocaCola"!

题目链接:

http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=2965

解题思路:

暴力打表即可。。。

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int vis[805];
int cnt[805];

int main(){
    memset(vis,0,sizeof(vis));
    memset(cnt,0,sizeof(cnt));
    for(int i = 1; i*7 <= 800; ++i)
        vis[i*7] = 1;
    for(int i = 1; i <= 800; ++i){
        int x = i;
        while(x){
            if(x%10 == 7){
                vis[i] = 1;
                break;
            }
            x /= 10;
        }
    }
    int flag = 0;
    for(int i = 800; i >= 1; --i){
        if(vis[i] && flag)
            cnt[i] = cnt[i+1]+1;
        else if(vis[i]){
            cnt[i] = 1;
            flag = 1;
        }
        else
            flag = 0;

    }
    int T;
    scanf("%d",&T);
    while(T--){
        int n;
        scanf("%d",&n);
        for(int i = 1; i <= 800; ++i){
            if(cnt[i] >= n){
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}

Build The Electric System

题目链接:

http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=2966

解题思路:

最小生成树。。。

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 1000005;
int n,m;
int pa[505];

struct Edge{
    int u,v,w;
}edge[N];


bool cmp(Edge a,Edge b){
    return a.w < b.w;
}

int findset(int x){
    if(pa[x] != x)
        pa[x] = findset(pa[x]);
    return pa[x];
}

int kruskal(){
    int cnt = n,sum = 0;
    for(int i = 0; i < m; i++){
        int u = findset(edge[i].u);
        int v = findset(edge[i].v);
        if(u != v){
            sum += edge[i].w;
            pa[v] = u;
            if(--cnt == 0)
                break;
        }
    }
    return sum;
}

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        scanf("%d%d",&n,&m);
        for(int i = 0; i <= n; ++i)
            pa[i] = i;
        int u,v,w;
        for(int i = 0; i < m; ++i)
            scanf("%d%d%d",&edge[i].u,&edge[i].v,&edge[i].w);
        sort(edge,edge+m,cmp);
        printf("%d\n",kruskal());
    }
    return 0;
}

Easy Task

题目链接:

http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=2969

解题思路:

简单模拟即可。。。

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int N = 1005;
int n,m;
int arr[N];
int arr2[N];

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        scanf("%d",&n);
        int tt = n+1; int sum = 0;
        for(int i = 0; i < tt; ++i){
            scanf("%d",&arr[i]);
            if(i != n)
                sum += arr[i];
        }
        if(sum == 0)
            printf("0\n");
        else{
            for(int i = 0; i < tt; ++i){
                int l = tt - i - 1;
                arr2[i] = arr[i] * l;
            }
            for(int i = 0; i < n-1; ++i)
                printf("%d ",arr2[i]);
            printf("%d\n",arr2[n-1]);
        }
    }
    return 0;
}

Faster, Higher, Stronger

题目链接:

http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=2970

解题思路:

水题。。。

AC代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

char str[1005];
int arr[100005];

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        scanf("%s",str);
        int n;
        scanf("%d",&n);
        for(int i = 0; i < n; ++i)
            scanf("%d",&arr[i]);
        sort(arr,arr+n);
        if(str[0] == 'F')
            printf("%d\n",arr[0]);
        else
            printf("%d\n",arr[n-1]);
    }
    return 0;
}

Give Me the Number

题目链接:

http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=2971

解题思路:

模拟即可。。。

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;

map<string,int> ma;

int main(){
    ma.clear();
    ma["zero"] = 0; ma["one"] = 1; ma["two"] = 2; ma["three"] = 3; ma["four"] = 4;
    ma["five"] = 5; ma["six"] = 6; ma["seven"] = 7; ma["eight"] = 8; ma["nine"] = 9;
    ma["ten"] = 10; ma["eleven"] = 11; ma["twelve"] = 12; ma["thirteen"] = 13; ma["fourteen"] = 14;
    ma["fifteen"] = 15; ma["sixteen"] = 16; ma["seventeen"] = 17; ma["eighteen"] = 18; ma["nineteen"] = 19;
    ma["twenty"] = 20; ma["thirty"] = 30; ma["forty"] = 40; ma["fifty"] = 50; ma["sixty"] = 60;
    ma["seventy"] = 70; ma["eighty"] = 80; ma["ninety"] = 90;
    int T;
    scanf("%d",&T);
    getchar();
    while(T--){
        string str,tmp = "";
        getline(cin,str);
        int len = str.size();
        int ans = 0,tmpans = 0;
        for(int i = 0; i <= len; ++i){
            if(i < len && str[i] != ' ')
                tmp += str[i];
            else{
                //cout<<tmp<<endl;
                if(tmp == "million")
                    ans += tmpans*1000000, tmpans = 0;
                else if(tmp == "thousand")
                    ans += tmpans*1000, tmpans = 0;
                else if(tmp == "hundred")
                     tmpans *= 100;
                else if(ma[tmp])
                    tmpans += ma[tmp];
                tmp = "";
                //cout<<tmpans<<endl;
            }
        }
        ans += tmpans;
        printf("%d\n",ans);
    }
    return 0;
}

Kinds of Fuwas

题目链接:

http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=2975

解题思路:

组合数学。。。

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

char maze[255][255];
int vis[255][255];
char fuwa[6] = "BJHYN";
int n,m;

int solve(char c){
    memset(vis,0,sizeof(vis));
    int cnt,res = 0;
    for(int i = 0; i < n-1; ++i){
        for(int j = 0; j < m-1; ++j){
            if(maze[i][j] == c){
                for(int k = j+1; k < m; ++k){
                    if(maze[i][k] == c && !vis[j][k]){
                        vis[j][k] = 1;
                        vis[k][j] = 1;
                        cnt = 1;
                        for(int p = i+1; p < n; ++p){
                            if(maze[p][j] == c && maze[p][k] == c)
                                ++cnt;
                        }
                        res += cnt*(cnt-1)/2;
                    }
                }
            }
        }
    }
    return res;
}

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        scanf("%d%d",&n,&m);
        for(int i = 0; i < n; ++i)
            scanf("%s",maze[i]);
        int ans = 0;
        for(int i = 0; i < 5; ++i)
            ans += solve(fuwa[i]);
        printf("%d\n",ans);
    }
    return 0;
}

Light Bulbs

题目链接:

http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=2975

解题思路:

题目大意:

上面有几盏灯(灯可以看做是点),每盏灯都有一定的光照强度,求地上的能接受到最多光强的点,求这个最大的光强。

算法思想:

因为数据量不大,所以可以直接暴力枚举。

如果数据很大的话,可以使用模拟退火。

AC代码:

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

struct Point{
    double x,y,z;
    double I;
    Point(){}
    Point(double _x,double _y,double _z){x = _x; y = _y; z = _z;}
}po[105];
int vis[105][105];

double get_dis(Point p,Point q){
    return sqrt((p.x-q.x)*(p.x-q.x)+(p.y-q.y)*(p.y-q.y)+(p.z-q.z)*(p.z-q.z));
}

double Dis(int n,Point q){
    double dis = 0;
    for(int i = 0; i < n; i++){
        double R = get_dis(po[i],q);
        dis += po[i].I/(R*R)*(po[i].z/R);
    }
    return dis;
}

double solve(int n){
    double ans = 0;
    for(int i = -100; i <= 100; ++i){
        for(int j = -100; j <= 100; ++j){
            ans = max(ans,Dis(n,Point(i,j,0)));
        }
    }
    return ans;
}

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        int n;
        scanf("%d",&n);
        for(int i = 0; i < n; i++)
            scanf("%lf%lf%lf%lf",&po[i].x,&po[i].y,&po[i].z,&po[i].I);
        printf("%.2lf\n",solve(n));
    }
    return 0;
}


《Android编程:The Big Nerd Ranch指南(第5版)》是一本针对Android编程的权威指南。这本书由Phillips、Stewart和Marsicano三位经验丰富的作者撰写,并由Big Nerd Ranch出版,对于想要学习和掌握Android编程的读者来说是一本必备的参考书。 这本书的第5版是一本全面更新和改进的指南,以帮助读者掌握最新的Android编程技术。它深入介绍了Android的核心概念和最佳实践,从而帮助读者全面了解Android应用的开发过程。 这本书以互动式的方式逐步引导读者进行Android应用开发,从创建一个简单的"Hello World"应用开始,逐渐深入介绍不同方面的开发技术,包括界面设计、数据存储和管理、网络通信、多媒体和设备功能等。 它采用了清晰明了的语言和丰富的示例代码,帮助读者理解和实践各种概念和技术。此外,这本书还通过挑战性练习和应用案例来培养读者的实际编程能力和解决问题的能力。 该书还引入了与现代开发实践相关的最新主题,例如响应式编程、单元测试和持续集成等。这些主题使读者能够更好地开发和维护高质量的Android应用。 总的来说,《Android编程:The Big Nerd Ranch指南(第5版)》是一本重要的Android编程指南,对于想要学习和应用这一技术的读者来说具有很高的实用价值。无论是初学者还是有经验的开发者,都可以通过这本书提供的深入理论和实践指导,加强他们的Android编程技能。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值