zoukankan      html  css  js  c++  java
  • 【ECJTU_ACM 11级队员2012年暑假训练赛(8) H Petya and Strings】

    B题要套一个数论的模版,注意m=1!! C题可以二分匹配,把行列看作点; 不能开百度,开谷歌搜题解,再次强调!一经发现,取消成绩!

    ECJTU_ACM 11级队员2012年暑假训练赛(8)
    4:30:00
     
     
              
    H - Petya and Strings
    Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

    Description

    Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. The letters' case does not matter, that is an uppercase letter is considered equivalent to the corresponding lowercase letter. Help Petya perform the comparison.

    Input

    Each of the first two lines contains a bought string. The strings' lengths range from 1 to 100 inclusive. It is guaranteed that the strings are of the same length and also consist of uppercase and lowercase Latin letters.

    Output

    If the first string is less than the second one, print "-1". If the second string is less than the first one, print "1". If the strings are equal, print "0". Note that the letters' case is not taken into consideration when the strings are compared.

    Sample Input

    Input
    aaaa
    aaaA
    Output
    0
    Input
    abs
    Abz
    Output
    -1
    Input
    abcdefg
    AbCdEfF
    Output
    1

    Hint

    If you want more formal information about the lexicographical order (also known as the "dictionary order" or "alphabetical order"), you can visit the following site:

    • http://en.wikipedia.org/wiki/Lexicographical_order

    FAQ | About Virtual Judge | Forum | Discuss | Open Source Project
    All Copyright Reserved ©2010-2012 HUST ACM/ICPC TEAM 
    Anything about the OJ, please ask in the forum, or contact author:Isun
    Server Time: 
     1 // Project name : H ( Petya and Strings ) 
     2 // File name    : main.cpp
     3 // Author       : iCoding
     4 // E-mail       : honi.linux@gmail.com
     5 // Date & Time  : Fri Aug 10 13:14:48 2012
     6 
     7 
     8 #include <iostream>
     9 #include <stdio.h>
    10 #include <string>
    11 #include <cmath>
    12 #include <algorithm>
    13 using namespace std;
    14 
    15 /*************************************************************************************/
    16 /* data */
    17 string sa, sb;
    18 
    19 /*************************************************************************************/
    20 /* procedure */
    21 
    22 int iCalForResult()
    23 {
    24     int iTop = sa.length() - 1;
    25     for (int i = 0; i <= iTop; i++)
    26     {
    27         if (sa[i] >= 'A' && sa[i] <= 'Z')
    28         {
    29             sa[i] += 32;
    30         }
    31         if (sb[i] >= 'A' && sb[i] <= 'Z')
    32         {
    33             sb[i] += 32;
    34         }
    35     }
    36 
    37     int res = 0;
    38     for (int i = 0; res == 0 && i <= iTop; i++)
    39     {
    40         if (sa[i] > sb[i])
    41         {
    42             res = 1;
    43         }
    44         else if (sa[i] < sb[i])
    45         {
    46             res = -1;
    47         }
    48     }
    49     return res;
    50 }
    51 /*************************************************************************************/
    52 /* main */
    53 int main()
    54 {
    55     while (cin >> sa >>sb)
    56     {
    57         cout << iCalForResult() << endl;
    58     }
    59     return 0;
    60 }
    61 
    62 // end 
    63 // Code by Sublime text 2
    64 // iCoding@CodeLab 
  • 相关阅读:
    spring4-2-bean配置-2-属性注入细节
    内存管理tcmalloc
    并发视频,怎么hold住高并发
    struts总结
    最近想玩的一个方向
    虚拟化技术漫谈
    陈硕的博客
    木铎
    安全编程资源-苹果
    POOL
  • 原文地址:https://www.cnblogs.com/ismdeep/p/2635986.html
Copyright © 2011-2022 走看看