青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

ACM___________________________

______________白白の屋
posts - 182, comments - 102, trackbacks - 0, articles - 0
<2010年9月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

常用鏈接

留言簿(24)

隨筆分類(332)

隨筆檔案(182)

FRIENDS

搜索

積分與排名

最新隨筆

最新評論

閱讀排行榜

評論排行榜

HDOJ 2714 HDU 2714 ISBN ACM 2714 IN HDU

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

MiYu原創, 轉帖請注明 : 轉載自 ______________白白の屋    

題目地址 :

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
 

 

題目分析 :

水題, 不錯還是 WA 了2次 , 很郁悶 , 主要是沒有注意到 題目描述中點一句話 :

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.

這句話是關鍵 , 意思就是 除了最后一個數字 可能是 X 外  其他的都只能為 0-9的數字.

 

代碼如下 :

 /*

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; //沒有這句代碼 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  回復  更多評論   

2012-03-09 21:40 by ACM小鳥~
謝謝 你的慷慨幫助。
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美在线观看网站| 欧美一级日韩一级| 免费久久99精品国产自在现线| 亚洲自拍偷拍视频| 国产精品日韩在线观看| 亚洲欧美日韩久久精品| 亚洲欧美另类国产| 国产性色一区二区| 免费成人高清视频| 欧美成人dvd在线视频| 亚洲乱码国产乱码精品精98午夜| 亚洲狠狠丁香婷婷综合久久久| 欧美3dxxxxhd| 亚洲天堂av在线免费观看| 亚洲一区精品视频| 精品va天堂亚洲国产| 亚洲电影av在线| 欧美日韩免费观看一区| 性色av一区二区三区| 欧美一区二区三区另类| 在线观看欧美黄色| 亚洲理论在线观看| 国产酒店精品激情| 欧美成人dvd在线视频| 欧美激情亚洲自拍| 亚洲欧美三级在线| 欧美中文在线观看| 亚洲美女诱惑| 亚洲一区二区三| 亚洲福利视频一区| 一本色道久久88综合亚洲精品ⅰ | 蜜臀久久99精品久久久久久9 | 亚洲国产综合在线| 日韩午夜电影av| 国产一区二区三区久久久久久久久 | 国产拍揄自揄精品视频麻豆| 欧美福利视频一区| 国产精品美女久久| 美女任你摸久久| 国产精品羞羞答答| 91久久精品一区二区三区| 国产一区二区三区久久 | 国产偷自视频区视频一区二区| 欧美激情第二页| 国产欧美在线| 亚洲午夜电影在线观看| 亚洲美女91| 久久偷看各类wc女厕嘘嘘偷窃| 午夜欧美不卡精品aaaaa| 欧美日韩a区| 亚洲激情在线观看视频免费| 国产综合亚洲精品一区二| 日韩视频一区二区在线观看 | 国产精品免费小视频| 亚洲精品免费一二三区| 亚洲国产天堂久久综合网| 午夜欧美大尺度福利影院在线看| 亚洲一区中文字幕在线观看| 欧美片第一页| 欧美国产欧美亚州国产日韩mv天天看完整 | 日韩视频免费观看高清在线视频 | 一区二区三区视频在线| 欧美国产91| 欧美激情国产日韩| 亚洲电影毛片| 久久一区二区三区四区五区| 男人的天堂亚洲在线| 精品不卡一区| 久久久夜夜夜| 欧美成人一区二区三区在线观看| 在线日韩一区二区| 久久国产乱子精品免费女| 久久久五月婷婷| 在线成人www免费观看视频| 久久久www成人免费毛片麻豆 | 亚洲一区二区在线免费观看| 欧美涩涩网站| 亚洲一区在线观看免费观看电影高清| 午夜视频精品| 国产最新精品精品你懂的| 久久精品男女| 欧美成人情趣视频| 亚洲精品综合久久中文字幕| 欧美久久久久久久久久| 亚洲网站在线观看| 欧美在线综合| 在线成人免费观看| 欧美顶级少妇做爰| 99在线精品观看| 久久精品亚洲| 91久久久久久久久久久久久| 欧美午夜寂寞影院| 香蕉久久夜色精品| 欧美sm视频| 亚洲一区在线直播| 国内揄拍国内精品少妇国语| 欧美激情一二区| 性色av一区二区三区| 猛男gaygay欧美视频| a91a精品视频在线观看| 国产美女在线精品免费观看| 久久综合五月| 亚洲欧美日韩国产成人| 蜜桃精品一区二区三区 | 国产综合婷婷| 欧美日韩国产成人在线| 欧美怡红院视频| 亚洲欧洲一二三| 久久精品日产第一区二区三区| 91久久黄色| 国产毛片一区| 欧美人成免费网站| 久久精品卡一| 亚洲一区日韩| 91久久久久久久久久久久久| 久久久久青草大香线综合精品| 亚洲伦伦在线| 在线观看日韩专区| 国产精品一二三视频| 欧美激情综合五月色丁香小说| 午夜精品视频在线观看一区二区| 亚洲精品国产精品国自产在线| 久久久伊人欧美| 性欧美精品高清| 亚洲一区二区视频在线| 亚洲欧洲免费视频| 国产自产在线视频一区| 欧美视频在线看| 欧美日韩1区2区| 欧美激情亚洲一区| 老司机午夜精品视频| 久久超碰97人人做人人爱| 亚洲在线视频网站| 正在播放亚洲一区| 日韩视频中文字幕| 亚洲国产成人不卡| 欧美91视频| 欧美 日韩 国产 一区| 久久久久久久综合狠狠综合| 欧美一站二站| 欧美一区二区国产| 亚洲欧美日韩国产一区二区| 亚洲影院高清在线| 亚洲无吗在线| 午夜精品久久久久99热蜜桃导演| 亚洲午夜精品久久久久久app| 一本综合精品| 亚洲一区中文| 欧美一区二区三区啪啪 | 亚洲韩国日本中文字幕| 影音先锋另类| 亚洲国产成人av在线| 亚洲国产网站| 亚洲美洲欧洲综合国产一区| 99ri日韩精品视频| 亚洲视频中文字幕| 亚洲欧美精品伊人久久| 久久不射2019中文字幕| 欧美在线视频一区二区| 久久久久久久欧美精品| 欧美1区免费| 亚洲毛片av| 亚洲欧美电影院| 久久综合狠狠| 欧美日韩精品一本二本三本| 国产精品久久久久久久久果冻传媒| 国产精品夜夜夜一区二区三区尤| 国产日韩精品久久久| 伊人伊人伊人久久| 一本色道久久综合亚洲精品不 | 午夜视频在线观看一区二区三区| 性欧美1819sex性高清| 久久夜色精品国产欧美乱极品| 欧美激情视频一区二区三区不卡| 日韩视频精品| 久久久一区二区三区| 欧美大秀在线观看| 国产精品欧美日韩久久| 伊人色综合久久天天| 亚洲最新色图| 久久青草久久| 在线视频欧美一区| 久久久久久久一区二区三区| 欧美午夜精品理论片a级按摩| 国产一区二区av| 99精品欧美一区二区蜜桃免费| 欧美一区精品| 亚洲精品日韩一| 久久精品72免费观看| 欧美日韩一区在线观看视频| 在线观看日韩www视频免费| 亚洲一区国产视频| 免费观看不卡av| 亚洲一区二区三区在线观看视频| 蜜乳av另类精品一区二区| 国产精品一区二区你懂得| 亚洲伦理在线观看| 久久躁狠狠躁夜夜爽| 亚洲一区网站| 欧美色道久久88综合亚洲精品|