• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            ACM___________________________

            ______________白白の屋
            posts - 182, comments - 102, trackbacks - 0, articles - 0
            <2010年11月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            常用鏈接

            留言簿(24)

            隨筆分類(332)

            隨筆檔案(182)

            FRIENDS

            搜索

            積分與排名

            最新隨筆

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            HDOJ 2714 HDU 2714 ISBN ACM 2714 IN HDU

            Posted on 2010-09-25 20:25 MiYu 閱讀(447) 評(píng)論(1)  編輯 收藏 引用 所屬分類: ACM ( 水題 )

            MiYu原創(chuàng), 轉(zhuǎn)帖請(qǐng)注明 : 轉(zhuǎn)載自 ______________白白の屋    

            題目地址 :

            http://acm.hdu.edu.cn/showproblem.php?pid=2714

            題目描述:

            ISBN

            Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
            Total Submission(s): 566    Accepted Submission(s): 172


            Problem Description
            Farmer John's cows enjoy reading books, and FJ has discovered that his cows produce more milk when they read books of a somewhat intellectual nature. He decides to update the barn library to replace all of the cheap romance novels with textbooks on algorithms and mathematics. Unfortunately, a shipment of these new books has fallen in the mud and their ISBN numbers are now hard to read.

            An ISBN (International Standard Book Number) is a ten digit code that uniquely identifies a book. The first nine digits represent the book and the last digit is used to make sure the ISBN is correct. To verify that an ISBN number is correct, you calculate a sum that is 10 times the first digit plus 9 times the second digit plus 8 times the third digit ... all the way until you add 1 times the last digit. If the final number leaves no remainder when divided by 11, the code is a valid ISBN.

            For example 0201103311 is a valid ISBN, since
            10*0 + 9*2 + 8*0 + 7*1 + 6*1 + 5*0 + 4*3 + 3*3 + 2*1 + 1*1 = 55.

            Each of the first nine digits can take a value between 0 and 9. Sometimes it is necessary to make the last digit equal to ten; this is done by writing the last digit as X. For example, 156881111X is a valid ISBN number.

            Your task is to fill in the missing digit from a given ISBN number where the missing digit is represented as '?'.
             

            Input
            * Line 1: A single line with a ten digit ISBN number that contains '?' in a single position
             

            Output
            * Line 1: The missing digit (0..9 or X). Output -1 if there is no acceptable digit for the position marked '?' that gives a valid ISBN.
             

            Sample Input
            15688?111X
             

            Sample Output
            1
             

            Source
             

             

            題目分析 :

            水題, 不錯(cuò)還是 WA 了2次 , 很郁悶 , 主要是沒(méi)有注意到 題目描述中點(diǎn)一句話 :

            Each of the first nine digits can take a value between 0 and 9. Sometimes it is necessary to make the last digit equal to ten; this is done by writing the last digit as X. For example, 156881111X is a valid ISBN number.

            這句話是關(guān)鍵 , 意思就是 除了最后一個(gè)數(shù)字 可能是 X 外  其他的都只能為 0-9的數(shù)字.

             

            代碼如下 :

             /*

            Coded By  : MiYu

            Link      : http://www.cnblogs.com/MiYu  || http://www.shnenglu.com/MiYu

            Author By : MiYu

            Test      : 1

            Program   : 2714

            */

            //#pragma warning( disable:4789 )

            #include <iostream>

            #include <algorithm>

            #include <string>

            #include <set>

            #include <map>

            #include <utility>

            #include <queue>

            #include <stack>

            #include <list>

            #include <vector>

            #include <cstdio>

            #include <cstdlib>

            #include <cstring>

            #include <cmath>

            using namespace std;

            int main ()

            {

                string str;

                while ( cin >> str )

                {

                      int N = str.size();

                      int sum = 0, ask = 0;

                      for ( int i = 1; i <= N; ++ i )

                      {

                           switch ( str[i-1] )

                           {

                                   case 'X':

                                            sum += (10-i+1) * 10;  break;

                                   case '?':

                                            ask = 10-i+1;  break;

                                   default :

                                            sum += (10-i+1) * (str[i-1] - '0');  break;      

                           }

                      } 

                      int pos = -1;

                      for ( int i = 0; i <= 10; ++ i )  

                      {

                           if ( ( sum + ask * i ) % 11 == 0 )

                           {

                                pos = i;

                                break;     

                           }    

                      } 

                      if ( ask != 1 && pos == 10 ) pos = -1; //沒(méi)有這句代碼 WA  2次  很郁悶.

                      if ( pos == 10 )

                         cout << 'X' << endl;  

                      else

                          cout << pos << endl;

                }

                return 0;

            }


             

            Feedback

            # re: HDOJ 2714 HDU 2714 ISBN ACM 2714 IN HDU  回復(fù)  更多評(píng)論   

            2012-03-09 21:40 by ACM小鳥(niǎo)~
            謝謝 你的慷慨幫助。
            久久久无码精品亚洲日韩蜜臀浪潮| 日本福利片国产午夜久久| 日日狠狠久久偷偷色综合免费| 亚洲?V乱码久久精品蜜桃| 亚洲午夜无码久久久久| 久久不见久久见免费视频7| 激情久久久久久久久久| 综合网日日天干夜夜久久| 久久亚洲综合色一区二区三区| 日韩美女18网站久久精品| 99久久精品国产高清一区二区| 久久亚洲中文字幕精品一区| 精品久久久久久亚洲精品| 亚洲欧洲精品成人久久曰影片| 伊人久久综合无码成人网| 久久中文字幕一区二区| 亚洲av伊人久久综合密臀性色| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 国产精品久久久久天天影视| 久久91精品国产91| 久久九九免费高清视频| 精品人妻久久久久久888| 久久亚洲AV无码精品色午夜| 久久久久久久亚洲精品| 国产成人精品久久一区二区三区av| 无码人妻久久一区二区三区免费 | 久久国产精品77777| 免费精品久久天干天干| 香蕉久久久久久狠狠色| 日韩欧美亚洲国产精品字幕久久久 | 精品久久久噜噜噜久久久 | 久久国产精品99精品国产987| 国产激情久久久久久熟女老人| 亚洲国产精品无码久久青草| 亚洲?V乱码久久精品蜜桃 | 久久国产免费观看精品3| 国产A三级久久精品| 色婷婷综合久久久中文字幕 | 久久久无码精品亚洲日韩京东传媒 | 亚洲一区精品伊人久久伊人| 久久亚洲国产精品五月天婷|