• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Codechef Code Crunch 2013 RD-CODE

 

RD-CODE

Problem code: MRIU12

 

  • Submit
  • All Submissions
 

Problem description.

Code Crunch Heads use RD-CODE for sending messages. It consists of only dots and dashes in sequence.
Below are the RD-CODE for the digits 0 to 9:

  • 0 -----
  • 1 .----
  • 2 ..---
  • 3 ...--
  • 4 ....-
  • 5 .....
  • 6 -....
  • 7 --...
  • 8 ---..
  • 9 ----.




    Using this code, help Code Crunch Members to find out the RD-CODE of their message.
    Users will enter 10 digit phone no. Convert these numbers to RD-CODE and also find no of dots used in the coded data.

    Input

    First line T, will have a single integer having number of test cases followed by T lines of input.




    Second line will have a 10-digit number N where N is a positive integer < 9999999999.

    Output

    First line will display the RD-Code for each digit together.


    Second line will display the total number of dots in the RD-CODE.

    Example

    Input:
    2
    9716733117
    9716335949
    .
    
    Output:
    ----.--….-----….--……--…--.----.------…
    23
    ----.--….-----…….--…--…..----…..-----.
    26
     1 #pragma comment(linker, "/STACK:1024000000,1024000000")
     2 #include <map>
     3 #include <queue>
     4 #include <vector>
     5 #include <string>
     6 #include <cstdio>
     7 #include <cstring>
     8 #include <iostream>
     9 #include <algorithm>
    10 using namespace std;
    11 #define maxn 10005
    12 #define mod 1000000007
    13 #define ll long long
    14 #define INF 0x7fffffff
    15 int n, m;
    16 char s[maxn];
    17 int main(){
    18     int cas = 1;
    19     int t;
    20     scanf("%d", &t);
    21     while (t--){
    22         scanf("%s", s);
    23         n = 0;
    24         char str[151] = "-----.----..---...--....-.....-....--...---..----.";
    25         for (int i = 0; i < strlen(s); i++){
    26             if (s[i]<='5')n += s[i] - '0';
    27             if (s[i] > '5')n += 5 - (s[i] - '0') % 5;
    28             for (int j = 0; j < 5; j++)printf("%c", str[(s[i] - '0') * 5 + j]);
    29         }
    30         printf("\n%d\n", n);
    31     }
    32     /*while (~scanf("%s", s)){
    33         
    34     }*/
    35     return 0;
    36 }
    View Code 2013-10-25 16:28:08
posted @ 2013-10-25 16:26  HaibaraAi  阅读(151)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3