zoukankan      html  css  js  c++  java
  • A hard puzzle

    Problem Description
    lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects to this BT problem,so lcy makes the problem easier than begin.
    this puzzle describes that: gave a and b,how to know the a^b's the last digit number.But everybody is too lazy to slove this problem,so they remit to you who is wise.
     
    Input
    There are mutiple test cases. Each test cases consists of two numbers a and b(0<a,b<=2^30)
     
    Output
    For each test case, you should output the a^b's last digit number.
     
    Sample Input
    7 66
    8 800
     
    Sample Output
    9
    6
     
      1 #include <stdio.h>
      2 
      3 int main(){
      4     int a;
      5     int b;
      6     int number;
      7     char two[5]="2486";
      8     char three[5]="3971";
      9     char four[3]="46";
     10     char seven[5]="7931";
     11     char eight[5]="8426";
     12     char nine[3]="91";
     13 
     14     while(scanf("%d%d",&a,&b)!=EOF){
     15         number=a%10;
     16 
     17         if(number==0){
     18             printf("0
    ");
     19             continue;
     20         }
     21 
     22         if(number==1){
     23             printf("1
    ");
     24             continue;
     25         }
     26 
     27         if(number==2){
     28             b%=4;
     29 
     30             if(b==0)
     31                 b=4;
     32 
     33             printf("%c
    ",two[b-1]);
     34             continue;
     35         }
     36 
     37         if(number==3){
     38             b%=4;
     39 
     40             if(b==0)
     41                 b=4;
     42 
     43             printf("%c
    ",three[b-1]);
     44             continue;
     45         }
     46 
     47         if(number==4){
     48             b%=2;
     49 
     50             if(b==0)
     51                 b=2;
     52 
     53             printf("%c
    ",four[b-1]);
     54             continue;
     55         }
     56 
     57         if(number==5){
     58             printf("5
    ");
     59             continue;
     60         }
     61 
     62         if(number==6){
     63             printf("6
    ");
     64             continue;
     65         }
     66 
     67         if(number==7){
     68             b%=4;
     69 
     70             if(b==0)
     71                 b=4;
     72 
     73             printf("%c
    ",seven[b-1]);
     74             continue;
     75         }
     76 
     77         if(number==8){
     78             b%=4;
     79 
     80             if(b==0)
     81                 b=4;
     82 
     83             printf("%c
    ",eight[b-1]);
     84             continue;
     85         }
     86 
     87         if(number==9){
     88             b%=2;
     89 
     90             if(b==0)
     91                 b=2;
     92 
     93             printf("%c
    ",nine[b-1]);
     94             continue;
     95 
     96         }
     97 
     98     }
     99     
    100     return 0;
    101 }
     
  • 相关阅读:
    cds.data:=dsp.data赋值有时会出现AV错误剖析
    iOS -- 十进制、十六进制字符串,byte,data等之间的转换
    iOS -- 原生NSStream实现socket
    CA认证原理以及实现(下)
    CA认证原理以及实现(上)
    android -- 存储byte
    iOS -- 字符串(NSString *)转uint8_t的两种方法
    Android -- AsyncTask 使用和缺陷
    Swift oc 混编
    Android -- native关键字
  • 原文地址:https://www.cnblogs.com/zqxLonely/p/4086933.html
Copyright © 2011-2022 走看看