A1042,A1046

//a1042
//注意下标越界
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    char c[5] = {'S', 'H', 'C', 'D', 'J'};
    int begin[55], finish[55], nowIndex[55];

    for (int i = 1; i <= 54; i++) {
        nowIndex[i] = i;
    }

    int k;
    scanf("%d", &k);

    //录入数据
    for (int i = 1; i <= 54; i++)
        scanf("%d", &begin[i]);

    //处理数据
    for (int i = 0; i < k; i++) {
        for (int j = 1; j <= 54; j++) {
            finish[begin[j]] = nowIndex[j];
        }

        for (int j = 1; j <= 54; j++)
            nowIndex[j] = finish[j];
    }

    //打印数据
    for (int i = 1; i <= 54; i++) {
        if (i != 1)
            printf(" ");
        nowIndex[i]--;
        printf("%c%d", c[nowIndex[i] / 13], nowIndex[i] % 13 + 1);
    }

    return 0;
}

//A1065
//注意推导距离
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    int N;
    scanf("%d", &N);

    //存储N个距离
    int dis[100010];
    //dis[1] 是第一个结点到第二个结点的距离
    //dis[2] 是第一个结点到第三个结点的距离
    int sumDis = 0;

    int keepDis[100010];
    for (int i = 1; i <= N; i++) {
        scanf("%d", &dis[i]);
        sumDis += dis[i];
        keepDis[i] = sumDis;
    }

    int M;
    scanf("%d", &M);
    int firstNode, secondNode;
    for (int i = 0; i < M; i++) {
        //  2  5
        //dis[4] 第一个结点到第五个结点的距离
        //dis[1] 第一个结点到第二个结点的距离
        scanf("%d%d", &firstNode, &secondNode);
        int tempDis;
        if (firstNode < secondNode)
            tempDis = keepDis[secondNode - 1] - keepDis[firstNode - 1];
        else {
            swap(firstNode, secondNode);
            tempDis = keepDis[secondNode - 1] - keepDis[firstNode - 1];
        }
        printf("%d\n", min(sumDis - tempDis, tempDis));

    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
RFC10xx 系列 RFC1000 - Obsoletes: RFCs 084, 100, 160, 170, 200, 598, 699, 800, 899, 999 RFC1001 - PROTOCOL STANDARD FOR A NetBIOS SERVICE RFC1002 - PROTOCOL STANDARD FOR A NetBIOS SERVICE RFC1003 - Issues in Defining an Equations Representation Standard RFC1004 - A Distributed-Protocol Authentication Scheme RFC1005 - The ARPANET AHIP-E Host Access Protocol (Enhanced AHIP) RFC1006 - ISO Transport Service on top of the TCP RFC1007 - MILITARY SUPPLEMENT RFC1008 - IMPLEMENTATION GUIDE RFC1009 - Requirements for Internet Gateways RFC1010 - ASSIGNED NUMBERS RFC1011 - OFFICIAL INTERNET PROTOCOLS RFC1012 - BIBLIOGRAPHY OF REQUEST FOR COMMENTS 1 THROUGH 999 RFC1013 - X WINDOW SYSTEM PROTOCOL, VERSION 11 RFC1014 - XDR: External Data Representation Standard RFC1015 - Implementation Plan for Interagency Research Internet RFC1016 - Something a Host Could Do with Source Quench: RFC1017 - Network Requirements for Scientific Research RFC1018 - Status of this Memo RFC1019 - Report of the Workshop on Environments for Computational Mathematics RFC1020 - INTERNET NUMBERS RFC1021 - THE HIGH-LEVEL ENTITY MANAGEMENT SYSTEM (HEMS) RFC1022 - THE HIGH-LEVEL ENTITY MANAGEMENT PROTOCOL (HEMP) RFC1023 - HEMS Monitoring and Control Language RFC1024 - HEMS VARIABLE DEFINITIONS RFC1025 - TCP AND IP BAKE OFF RFC1026 - Addendum to RFC 987 RFC1027 - Using ARP to Implement Transparent Subnet Gateways RFC1028 - A Simple Gateway Monitoring Protocol RFC1029 - A MORE FAULT TOLERANT APPROACH TO ADDRESS RESOLUTION FOR RFC1030 - On Testing the NETBLT Protocol over Divers Networks RFC1031 - MILNET NAME DOMAIN TRANSITION RFC1032 - DOMAIN ADMINISTRATORS GUIDE RFC1033 - DOMAIN ADMINISTRATORS OPERATIONS GUIDE RFC1034 - DOMAIN NAMES - CONCEPTS AND FACILITIES RFC1035 - DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION RFC1036 - Standard for Interchange of USENET Messages RFC1037 - NFILE - A File Access Protocol RFC1038 - Draft Revised IP Security Option RFC1039 - A DoD Statement o
ZJU_Main 主页 下一页 ZJU 题型分类 文演整理版 2008-3-23 数论: 1007 Numerical Summation of a Series 简单题,还是蛮有意思的 1045 HangOver 简单题 1049 I Think I Need a Houseboat 简单题 1028 Flip and Shift 简单题,可以DP/BFS/……,但是实际上有数学方法可直接判断出来 1026 Modular multiplication of polynomials 简单题,有比较简单的好算法 1307 Packets 简单题,不过也蛮经典的…… 1312 Prime Cuts 简单题 1334 Basically Speaking 简单题 1337 Pi 简单题 1342 Word Index 简单题 1349 Four Quarters 简单题 1350 The Drunk Jailer 简单题 1352 Number Base Conversion 简单题 1353 Unimodal Palindromic Decompositions 规模不大,所以是简单题…… 1354 Extended Lights Out 简单题 1362 Game Prediction 简单题 1365 Mileage Bank 简单题 1382 A Simple Task 简单题 1383 Binary Numbers 简单题 1403 Safecracker 简单题 1408 The Fun Number System 简单题 1486 Color the Tree 简单题 1487 Playing Cards 简单题 1489 2^x mod n = 1 简单题,应该有好算法,不过枚举就可以过…… 1503 One Person "The Price is Right" 简单题,POI Eggs的翻版 1512 Water Treatment Plants 简单题,组合计数 1526 Big Number 简单题,不过O(1)和O(n)还是有区别的:) 1529 Enigmatic Travel 简单题,不过个人感觉题目描述很令人费解 1530 Find The Multiple 简单题 1537 Playing with a Calculator 简单题 1577 GCD & LCM 简单题,分区联赛的题…… 1005 Jugs 简单题 1543 Stripies 简单题 1569 Partial Sums 简单题 1062 Trees Made to Order 简单题 1070 Bode Plot 简单题 1073 Round and Round We Go 简单题,142857,我喜欢^_^ 1078 Palindrom Numbers 简单题 1086 Octal Fractions 简单题 1199 Point of Intersection 简单题 1104 Leaps Tall Buildings 简单题 1110

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值